标签:puts inpu max size tom bit 行数据 通过 还需
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 13641 Accepted Submission(s):
6450
#include<bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
int dp[105][105];
int main()
{
int n,m,k,s,d,a,b,i,j;
while(cin>>n>>m>>k>>s){ int ans=inf;
memset(dp,0,sizeof(dp));
for(i=1;i<=k;++i){
cin>>a>>b;
for(j=b;j<=m;++j)
for(d=1;d<=s;++d){
dp[j][d]=max(dp[j][d],dp[j-b][d-1]+a);
if(dp[j][d]>=n) ans=min(ans,j);
}
}
if(ans<=m) cout<<m-ans<<endl;
else puts("-1");
}
return 0;
}
标签:puts inpu max size tom bit 行数据 通过 还需
原文地址:http://www.cnblogs.com/zzqc/p/6789385.html