Obviously the DP, speaking several important places
1. greedy: Let's eat a long time to line up (proof omitted)
2. Status:
f [i] [j] [k] i personal representative of the former, One time j, k is clearly time MLE II
So compressed into the front f [i] [j] i represents individuals One time j, with prefixes and maintenance time, s [i] -j II is the time
Code:
. 1 #include <bits / STDC ++ H.> 2 the using namespace STD; . 3 struct the Person { . 4 int Take, EAT; . 5 BOOL operator <(the Person Ano) const { . 6 return EAT> ano.eat; . 7 } . 8 } P [ 233 ]; . 9 int n-, ANS, S [ 233 ], F [ 233 ] [ 233 * 233 ]; // time to open square 10 inline void the Init () { . 11 CIN >>n; 12 for(int i=1;i<=n;i++)cin>>p[i].take>>p[i].eat; 13 sort(p+1,p+1+n);//贪心 14 //前缀和 15 for(int i=1;i<=n;i++)s[i]=s[i-1]+p[i].take; 16 memset(f,0x3f,sizeof(f)); 17 ans=0x3f3f3f3f; 18 f[0][0]=0; 19 } 20 inline void DP(){ 21 for(int i=1;i<=n;i++){ 22 for(int j=0;j<=s[i];j++){ 23 //去一号窗口 24 if(j>=p[i].take)f[i][j]=min(f[i][j],max(f[i-1][j-p[i].take],j+p[i].eat)); 25 //去二号窗口 26 f[i][j]=min(f[i][j],max(f[i-1][j],s[i]-j+p[i].eat)); 27 } 28 } 29 for(int I = 0 ; I <= S [n-]; I ++) ANS = min (ANS, F [n-] [I]); 30 COUT ANS << << endl; 31 is } 32 int main () { // Ultra simple main 33 is the Init (); 34 is the DP (); 35 return 0 ; 36 }