Main » 2013 August 21 » 神奇的STL
10:34 AM 神奇的STL |
Prob.
Code. #include<cstdio> #include<cstdlib> #include<set> #define ittype multiset<int>::iterator #define N 200100 using namespace std; multiset<int> dp; int n,L,R,i,tot; int a[N],f[N]; int main() { scanf("%d %d %d",&n,&L,&R); for (i=0;i<=n;i++) scanf("%d",&a[i]); f[0]=0; for (i=1;i<=L-1;i++) f[i]=-100000000; for (i=L;i<=2*n;i++) { if ((i-1-R)>=0) { ittype it=dp.find(f[i-1-R]); dp.erase(it); } dp.insert(f[i-L]); ittype it=dp.end(); it--; int m=*it; f[i]=m+a[i]; } printf("%d\n",f[2*n]); } |
|
Total comments: 0 | |