/*Space 32000 I wrote it all 31900+ drunk can reduce dimensional optimization space of the lazy wrote the state: F[i][j] The former I topic a altogether did J minute B The least do the problem time shift: Consider each topic to who do f[i][j] = min (f[i-1][j-a]a do, f[ I-1][j]+b b); Finally, the question Time of F[n] enumeration A is updated with the answer*/#include<iostream>#include<cstdio>#include<cstring>#defineMAXN 201using namespacestd;intn,a,b,sum,ans=0x3f3f3f3f, f[maxn][maxn*MAXN];intMain () {scanf ("%d",&N); Memset (F,127/3,sizeof(f)); f[0][0]=0; for(intI=1; i<=n;i++) {scanf ("%d%d", &a,&b); sum+=b; f[i][0]=sum; for(intj=0; j<=40000; j + +) if(j>=a) F[i][j]=min (f[i-1][j-a],f[i-1][j]+b); Elsef[i][j]=f[i-1][j]+b; } for(intI=1; i<=40000; i++) ans=min (Ans,max (i,f[n][i)); printf ("%d\n", ans); return 0;}
Codevs 50,591 to play CS