- 朴素的网络游戏
- 2017-07-13 08:42:50 @
我没有处理“impossible"的情况居然Ac了??请加强数据,谢谢
2 条评论
-
Administrator2004 LV 7 @ 2017-07-13 08:59:05
wa
-
2017-07-13 08:47:33@
#include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #include<vector> using namespace std; const int maxn=300+5; int m,f,n,c; int b[maxn],p[maxn]; int dp1[maxn][maxn][maxn],dp2[maxn][maxn][maxn]; int main() { ios::sync_with_stdio(false); memset(dp1,0x7f,sizeof(dp1)); memset(dp2,0x7f,sizeof(dp2)); dp1[0][0][0]=0;dp2[0][0][0]=0; cin>>m>>f>>n>>c; for(int i=1; i<=n; i++) cin>>b[i]>>p[i]; for(int i=1; i<=n; i++) { for(int j=0; j<=m; j++) { for(int k=0; k<=f; k++) { dp1[i][j][k]=min(dp1[i-1][j][k],min(dp1[i-1][max(0,j-b[i])][k]+p[i],dp1[i-1][j][max(0,k-b[i])]+p[i])); if(b[i]>=2 && j>=1 && k>=1 && i>=1) dp2[i][j][k]=min(dp2[i][j][k],dp1[i-1][j-1][k-1]+p[i]); dp2[i][j][k]=min(dp2[i-1][j][k],min(dp2[i-1][max(0,j-b[i])][k]+p[i],dp2[i-1][j][max(0,k-b[i])]+p[i])); } } } int ans=2147483647; ans=min(dp1[n][m][f],dp2[n][m][f]); //if(ans>=2139062143) // cout<<"impossible"; else cout<<ans; return 0; }
这居然能Ac????
- 1