# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
127377 | 2019-07-09T09:42:21 Z | sealnot123 | Popeala (CEOI16_popeala) | C++14 | 2000 ms | 5752 KB |
#include<bits/stdc++.h> #define x first #define y second #define all(x) (x).begin(),(x).end() #define SZ(x) (int)(x).size() #define push_back pb #define emplace_back eb using namespace std; typedef long long LL; typedef double DD; typedef long double LD; typedef pair<int,int> PII; typedef pair<LL,LL> PLL; const int T = 20007, N = 52; LL dp[T][N], last[T][N], qs[T]; char str[T]; int main(){ int n, t, s; int i,j,k,l,a,b,c,d; scanf("%d%d%d",&n,&t,&s); for(i=1;i<=t;i++) scanf("%lld",&qs[i]), qs[i]+=qs[i-1]; for(i=1;i<=n;i++){ scanf(" %s",str+1); for(j=1;j<=t;j++){ if(str[j]=='1') last[j][i] = last[j-1][i]; else last[j][i] = j; /*printf("%lld ",last[j][i]);*/ } /*printf("\n");*/ } for(i=1;i<=s;i++) dp[0][i] = 1e16; for(i=1;i<=t;i++) dp[i][0] = 1e16; for(i=1;i<=t;i++){ sort(last[i]+1, last[i]+1+n); for(j=1;j<=s;j++){ dp[i][j] = 1e16; LL p = n; for(k=i;k>0;k--){ while(last[i][p]>=k) p--; dp[i][j] = min(dp[i][j], dp[k-1][j-1] + (qs[i]-qs[k-1])*p); } /*printf("%lld ",dp[i][j]);*/ } /*printf("\n");*/ } for(i=1;i<=s;i++) printf("%lld\n",dp[t][i]); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 17 ms | 760 KB | Output is correct |
2 | Correct | 18 ms | 760 KB | Output is correct |
3 | Correct | 18 ms | 760 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 299 ms | 2268 KB | Output is correct |
2 | Correct | 592 ms | 2936 KB | Output is correct |
3 | Correct | 1124 ms | 3804 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 17 ms | 760 KB | Output is correct |
4 | Correct | 18 ms | 760 KB | Output is correct |
5 | Correct | 18 ms | 760 KB | Output is correct |
6 | Correct | 299 ms | 2268 KB | Output is correct |
7 | Correct | 592 ms | 2936 KB | Output is correct |
8 | Correct | 1124 ms | 3804 KB | Output is correct |
9 | Execution timed out | 2032 ms | 5752 KB | Time limit exceeded |
10 | Halted | 0 ms | 0 KB | - |