# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
874890 | 2023-11-18T03:36:34 Z | Faisal_Saqib | Popeala (CEOI16_popeala) | C++17 | 634 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() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 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[0][0]=0; 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 | 22 ms | 41564 KB | Output is correct |
2 | Correct | 20 ms | 41564 KB | Output is correct |
3 | Correct | 20 ms | 41576 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 350 ms | 177132 KB | Output is correct |
2 | Correct | 634 ms | 240976 KB | Output is correct |
3 | Runtime error | 577 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 | 22 ms | 41564 KB | Output is correct |
4 | Correct | 20 ms | 41564 KB | Output is correct |
5 | Correct | 20 ms | 41576 KB | Output is correct |
6 | Correct | 350 ms | 177132 KB | Output is correct |
7 | Correct | 634 ms | 240976 KB | Output is correct |
8 | Runtime error | 577 ms | 262144 KB | Execution killed with signal 9 |
9 | Halted | 0 ms | 0 KB | - |