Note that there is only one factor in the case.
1#include <cstdio>2#include <algorithm>3#include <cstring>4 5 using namespacestd;6 7typedefLong Longll;8 Const intINF =0x3f3f3f3f;9 Const intMAXN = 4e3+Ten;Ten structCake One { A intw,l; - cake () {} - BOOL operator< (ConstCake &b)Const the { - returnL >B.L; - } - }CK[MAXN]; + - intN,LEN[MAXN]; + A intMain () at { -scanf"%d",&N); - - for(intI=0; i<n;i++) - { -scanf"%d%d",&ck[i].w,&ck[i].l); in if(Ck[i].w >ck[i].l) Swap (CK[I].W,CK[I].L); - } to +Sort (ck,ck+N); - the intm; * intAnsw,ansl; $ll ans =-INF;Panax Notoginseng - for(intI=0; i<n;i++) the { +m =0; A for(intj=0; j<n;j++) the { + if(CK[J].W >=CK[I].W) - { $len[m++] =CK[J].L; $ } - } - for(intj=0; j<m;j++) the { -ll res = (ll) ck[i].w*len[j]* (j+1);Wuyi if(Res >ans) the { -Ans =Res; WuANSW =CK[I].W; -Ansl =Len[j]; About } $ } - } -printf"%i64d\n%d%d\n", ANS,ANSW,ANSL); - A}
HDU 4344-mark The rope-factorization of large numbers of elements