# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
223570 | 2020-04-15T13:15:00 Z | MKopchev | 조교 (CEOI16_popeala) | C++14 | 2000 ms | 1680 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 prv_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(prv_bad[i][r]<l)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++) { for(int j=1;j<=tasks;j++) if(solved[i][j]==0)prv_bad[i][j]=j; else prv_bad[i][j]=prv_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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 640 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 514 ms | 1144 KB | Output is correct |
2 | Correct | 485 ms | 1272 KB | Output is correct |
3 | Correct | 514 ms | 1404 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2088 ms | 1680 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 640 KB | Output is correct |
3 | Correct | 514 ms | 1144 KB | Output is correct |
4 | Correct | 485 ms | 1272 KB | Output is correct |
5 | Correct | 514 ms | 1404 KB | Output is correct |
6 | Execution timed out | 2088 ms | 1680 KB | Time limit exceeded |
7 | Halted | 0 ms | 0 KB | - |