# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
63162 | 2018-08-01T01:33:55 Z | khsoo01 | Popeala (CEOI16_popeala) | C++11 | 926 ms | 60120 KB |
#include<bits/stdc++.h> #define X first #define Y second using namespace std; typedef long long ll; typedef pair<ll,ll> pll; const ll N = 55, T = 20005, inf = 1e12; ll n, t, s, p[T], a[N][T], dt[N][T], pre[T][N], nxt[N][T]; char ipt[T]; vector<pll> pot[T]; ll getv (ll S, ll E) { ll R = 0; for(int i=1;i<=n;i++) { if(a[i][E] - a[i][S-1] == E-S+1) R++; } return R; } int main() { scanf("%lld%lld%lld",&n,&t,&s); for(int i=1;i<=t;i++) { scanf("%lld",&p[i]); p[i] += p[i-1]; } for(int i=1;i<=n;i++) { scanf("%s",ipt+1); for(int j=1;j<=t;j++) { a[i][j] = (ipt[j] == '1'); nxt[i][j] = (a[i][j] ? nxt[i][j-1] : j); a[i][j] += a[i][j-1]; } } for(int i=1;i<=t;i++) { for(int j=1;j<=n;j++) { if(!nxt[j][i]) continue; pot[i].push_back({nxt[j][i]-1, getv(nxt[j][i], i)}); } pot[i].push_back({i-1, getv(i, i)}); } for(int i=1;i<=t;i++) { dt[1][i] = getv(1, i) * p[i]; } for(int i=2;i<=s;i++) { for(int k=i-1;k<=t;k++) { for(int j=0;j<=n;j++) { pre[k][j] = dt[i-1][k] - j * p[k]; if(k >= i) pre[k][j] = min(pre[k-1][j], pre[k][j]); } } for(int j=i;j<=t;j++) { dt[i][j] = inf; for(auto &T : pot[j]) { ll A, B; tie(A, B) = T; if(A < i-1) continue; dt[i][j] = min(dt[i][j], pre[A][B] + B * p[j]); } } } for(int i=1;i<=s;i++) { printf("%lld\n",dt[i][t]); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 760 KB | Output is correct |
2 | Correct | 4 ms | 1256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 19 ms | 2836 KB | Output is correct |
2 | Correct | 18 ms | 2852 KB | Output is correct |
3 | Correct | 20 ms | 3000 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 73 ms | 7428 KB | Output is correct |
2 | Correct | 96 ms | 9876 KB | Output is correct |
3 | Correct | 167 ms | 12672 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 760 KB | Output is correct |
2 | Correct | 4 ms | 1256 KB | Output is correct |
3 | Correct | 19 ms | 2836 KB | Output is correct |
4 | Correct | 18 ms | 2852 KB | Output is correct |
5 | Correct | 20 ms | 3000 KB | Output is correct |
6 | Correct | 73 ms | 7428 KB | Output is correct |
7 | Correct | 96 ms | 9876 KB | Output is correct |
8 | Correct | 167 ms | 12672 KB | Output is correct |
9 | Correct | 241 ms | 19392 KB | Output is correct |
10 | Correct | 384 ms | 25360 KB | Output is correct |
11 | Correct | 803 ms | 54984 KB | Output is correct |
12 | Correct | 869 ms | 56696 KB | Output is correct |
13 | Correct | 926 ms | 58128 KB | Output is correct |
14 | Correct | 871 ms | 59224 KB | Output is correct |
15 | Correct | 887 ms | 60120 KB | Output is correct |