# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
874887 | 2023-11-18T03:33:41 Z | Faisal_Saqib | Popeala (CEOI16_popeala) | C++17 | 679 ms | 262144 KB |
#include <iostream> #include <vector> #include <algorithm> using namespace std; const int T=2e4+10; const int N=52; const int inf=2e9+1; int points[1]; string results[1]; int pre[T]; int ptr[N]; vector<int> zero[N]; int zeros[T][T]; int dp[T][N]; int main() { int n,t,s; cin>>n>>t>>s; for(int i=0;i<t;i++) { cin>>points[0]; pre[i+1]=pre[i]+points[0]; } for(int i=0;i<n;i++) { cin>>results[0]; ptr[i]=0; for(int j=0;j<t;j++) if(results[0][j]=='0') zero[i].push_back(j); } for(int i=0;i<=t;i++) for(int j=0;j<=s;j++) dp[i][j]=inf; // dp[i][j] we spilt the first i testcases into j subtask dp[0][0]=0; // dp[i][j] ---> dp[i+1..n][j+1] for(int l=1;l<=t;l++) { for(int r=l;r<=t;r++) { zeros[l][r]=n; for(int i=0;i<n;i++) { while(ptr[i]<zero[i].size() and zero[i][ptr[i]]<(l-1)) ptr[i]++; if(ptr[i]<zero[i].size() and zero[i][ptr[i]] < r) zeros[l][r]--; } } } for(int i=0;i<t;i++) { for(int j=0;j<s;j++) { if(dp[i][j]==inf) continue; for(int new_i=i+1;new_i<=t;new_i++) { dp[new_i][j+1]=min(dp[new_i][j+1],dp[i][j]+(pre[new_i]-pre[i])*zeros[i+1][new_i]); } } } for(int j=1;j<=s;j++) cout<<dp[t][j]<<'\n'; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 4444 KB | Output is correct |
2 | Correct | 1 ms | 6492 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 24 ms | 41564 KB | Output is correct |
2 | Correct | 22 ms | 41536 KB | Output is correct |
3 | Correct | 26 ms | 42060 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 360 ms | 177048 KB | Output is correct |
2 | Correct | 679 ms | 241052 KB | Output is correct |
3 | Runtime error | 622 ms | 262144 KB | Execution killed with signal 9 |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 4444 KB | Output is correct |
2 | Correct | 1 ms | 6492 KB | Output is correct |
3 | Correct | 24 ms | 41564 KB | Output is correct |
4 | Correct | 22 ms | 41536 KB | Output is correct |
5 | Correct | 26 ms | 42060 KB | Output is correct |
6 | Correct | 360 ms | 177048 KB | Output is correct |
7 | Correct | 679 ms | 241052 KB | Output is correct |
8 | Runtime error | 622 ms | 262144 KB | Execution killed with signal 9 |
9 | Halted | 0 ms | 0 KB | - |