# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
933003 | sleepntsheep | Schools (IZhO13_school) | C++17 | 12 ms | 15960 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<stdio.h>
int hi(int a,int b){return a>b?a:b;}
unsigned X=12345;int rand_(){return(X*=3)/2;}
int (*compar)(int,int);
void sort(int*aa,int l,int r){
while(l<r){int i=l,j=l,k=r,tmp,p=aa[l+rand_()%(r-l)];
while(j<k)switch(compar(aa[j],p)){case 0:++j;break;case -1:tmp=aa[j],aa[j]=aa[i],aa[i]=tmp,++i,++j;break;case 1:tmp=aa[--k],aa[k]=aa[j],aa[j]=tmp;break;}sort(aa,l,i);l=k;}}
#define N 505
int n,m,s,a[N],b[N],dp[N][N][N];long long z;
int main(){
scanf("%d%d%d",&n,&m,&s);for(int i=1;i<=n;++i)scanf("%d%d",a+i,b+i);
for(int i=1;i<=n;++i)
{
for(int j=0;j<=m;++j)
{
for(int k=0;k<=s;++k)
{
dp[i][j][k]=hi(dp[i][j][k],dp[i-1][j][k]);
if(j)
dp[i][j][k]=hi(dp[i][j][k],dp[i-1][j-1][k]+a[i]);
if(k)
dp[i][j][k]=hi(dp[i][j][k],dp[i-1][j][k-1]+b[i]);
z=hi(z,dp[i][j][k]);
}
}
}
printf("%lld",z);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |