# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
223558 | 2020-04-15T11:46:46 Z | MKopchev | Popeala (CEOI16_popeala) | C++14 | 2000 ms | 1588 KB |
#include<bits/stdc++.h> using namespace std; const int nmax=50+5,tmax=20000+5,inf=2e9+42; int n,tasks,want; int points[tmax]; bool solved[nmax][tmax]; int nxt_bad[nmax][tmax]; int pref[nmax]; int ask(int l,int r) { int ret=0,sum=pref[r]-pref[l-1]; for(int i=1;i<=n;i++) if(nxt_bad[i][l]>r)ret=ret+sum; return ret; } int dp[nmax][tmax]; int main() { scanf("%i%i%i",&n,&tasks,&want); for(int i=1;i<=tasks;i++)scanf("%i",&points[i]); for(int i=1;i<=tasks;i++)pref[i]=pref[i-1]+points[i]; for(int i=1;i<=n;i++) for(int j=1;j<=tasks;j++) { char in=getchar(); while(in!='0'&&in!='1')in=getchar(); if(in=='1')solved[i][j]=1; } for(int i=1;i<=n;i++) { nxt_bad[i][tasks+1]=tasks+1; for(int j=tasks;j>=1;j--) if(solved[i][j]==0)nxt_bad[i][j]=j; else nxt_bad[i][j]=nxt_bad[i][j+1]; } /* for(int i=1;i<=n;i++) for(int j=1;j<=tasks;j++) cout<<i<<" "<<j<<" -> "<<nxt_bad[i][j]<<endl; */ for(int i=1;i<=tasks;i++) dp[0][i]=inf; for(int sub=1;sub<=want;sub++) { dp[sub][0]=inf; for(int i=1;i<=tasks;i++) { dp[sub][i]=inf; for(int cur=i;cur>=1;cur--) if(dp[sub-1][cur-1]!=inf) { dp[sub][i]=min(dp[sub][i],dp[sub-1][cur-1]+ask(cur,i)); } //cout<<sub<<" "<<i<<" -> "<<dp[sub][i]<<endl; } printf("%i\n",dp[sub][tasks]); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 640 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 415 ms | 1144 KB | Output is correct |
2 | Correct | 411 ms | 1216 KB | Output is correct |
3 | Correct | 413 ms | 1144 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2084 ms | 1588 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 640 KB | Output is correct |
3 | Correct | 415 ms | 1144 KB | Output is correct |
4 | Correct | 411 ms | 1216 KB | Output is correct |
5 | Correct | 413 ms | 1144 KB | Output is correct |
6 | Execution timed out | 2084 ms | 1588 KB | Time limit exceeded |
7 | Halted | 0 ms | 0 KB | - |