답안 #933003

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
933003 2024-02-24T18:40:41 Z sleepntsheep 학교 설립 (IZhO13_school) C++17
30 / 100
12 ms 15960 KB
#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

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);
      |                                                   ~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 3 ms 5724 KB Output is correct
5 Correct 1 ms 1368 KB Output is correct
6 Correct 9 ms 15960 KB Output is correct
7 Runtime error 10 ms 344 KB Execution killed with signal 11
8 Runtime error 10 ms 348 KB Execution killed with signal 11
9 Runtime error 10 ms 428 KB Execution killed with signal 11
10 Runtime error 10 ms 344 KB Execution killed with signal 11
11 Runtime error 10 ms 468 KB Execution killed with signal 11
12 Runtime error 10 ms 464 KB Execution killed with signal 11
13 Runtime error 10 ms 464 KB Execution killed with signal 11
14 Runtime error 10 ms 344 KB Execution killed with signal 11
15 Runtime error 10 ms 348 KB Execution killed with signal 11
16 Runtime error 12 ms 468 KB Execution killed with signal 11
17 Runtime error 10 ms 348 KB Execution killed with signal 11
18 Runtime error 10 ms 460 KB Execution killed with signal 11
19 Runtime error 10 ms 464 KB Execution killed with signal 11
20 Runtime error 10 ms 348 KB Execution killed with signal 11