Submission #933003

#TimeUsernameProblemLanguageResultExecution timeMemory
933003sleepntsheepSchools (IZhO13_school)C++17
30 / 100
12 ms15960 KiB
#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)

school.cpp: In function 'void sort(int*, int, int)':
school.cpp:7:8: warning: this 'while' clause does not guard... [-Wmisleading-indentation]
    7 |        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;}}
      |        ^~~~~
school.cpp:7:161: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'
    7 |        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;}}
      |                                                                                                                                                                 ^~~~
school.cpp: In function 'int main()':
school.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     scanf("%d%d%d",&n,&m,&s);for(int i=1;i<=n;++i)scanf("%d%d",a+i,b+i);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
school.cpp:12:56: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     scanf("%d%d%d",&n,&m,&s);for(int i=1;i<=n;++i)scanf("%d%d",a+i,b+i);
      |                                                   ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...