# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
148075 | 2019-08-31T13:40:25 Z | WhipppedCream | 조교 (CEOI16_popeala) | C++17 | 376 ms | 16632 KB |
#include <bits/stdc++.h> #pragma GCC optimize ("O3") #pragma GCC target ("sse4") using namespace std; #define X first #define Y second #define pb push_back typedef pair<int, int> ii; typedef long long ll; const int maxt = 2e4+5; const int maxn = 55; ll pts[maxt]; char foo[maxn][maxt]; int n, t, s; vector<int> lims[maxt]; ll mem[maxt]; ll dp[maxn][maxt]; void clear() { for(int i = 0; i<= n; i++) mem[i] = 1e18+5; } int main() { scanf("%d %d %d", &n, &t, &s); for(int i = 1; i<= t; i++) { scanf("%lld", &pts[i]); pts[i] += pts[i-1]; } for(int i = 1; i<= n; i++) { scanf("%s", foo[i]+1); } for(int i = 1; i<= n; i++) { int last = 0; for(int j = 1; j<= t; j++) { if(foo[i][j] == '1') { lims[j].pb(last); } else { lims[j].pb(j); last = j; } } } for(int i = 1; i<= t; i++) { lims[i].pb(i); sort(lims[i].begin(), lims[i].end()); } for(int i = 0; i<= s; i++) { for(int j = 0; j<= t; j++) { dp[i][j] = 1e18; } } dp[0][0] = 0; for(int i = 1; i<= s; i++) { clear(); for(int j = 1; j<= t; j++) { // printf("computing %d\n", j); for(int k = 0; k<= n; k++) { for(int run = j>1?lims[j-1][k]:0; run< lims[j][k]; run++) { mem[k] = min(mem[k], dp[i-1][run]-pts[run]*k); // if(k == 0) printf("cand2 %d-%d\n", dp[i-1][run], pts[run]*k); } // printf("[%d..%d), %d\n", j>1?lims[j-1][k]:0, lims[j][k], mem[k]); if(lims[j][k]> 0) dp[i][j] = min(dp[i][j], mem[k]+k*pts[j]); // printf("cand %d\n", mem[k]+k*pts[j]); } // printf("dp[%d][%d] = %d\n", i, j, dp[i][j]); } printf("%lld\n", dp[i][t]); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 888 KB | Output is correct |
2 | Correct | 3 ms | 1016 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 13 ms | 1660 KB | Output is correct |
2 | Correct | 12 ms | 1656 KB | Output is correct |
3 | Correct | 13 ms | 1656 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 51 ms | 2988 KB | Output is correct |
2 | Correct | 70 ms | 3656 KB | Output is correct |
3 | Correct | 79 ms | 4344 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 888 KB | Output is correct |
2 | Correct | 3 ms | 1016 KB | Output is correct |
3 | Correct | 13 ms | 1660 KB | Output is correct |
4 | Correct | 12 ms | 1656 KB | Output is correct |
5 | Correct | 13 ms | 1656 KB | Output is correct |
6 | Correct | 51 ms | 2988 KB | Output is correct |
7 | Correct | 70 ms | 3656 KB | Output is correct |
8 | Correct | 79 ms | 4344 KB | Output is correct |
9 | Correct | 106 ms | 6352 KB | Output is correct |
10 | Correct | 169 ms | 7928 KB | Output is correct |
11 | Correct | 288 ms | 16376 KB | Output is correct |
12 | Correct | 305 ms | 16520 KB | Output is correct |
13 | Correct | 369 ms | 16632 KB | Output is correct |
14 | Correct | 376 ms | 16632 KB | Output is correct |
15 | Correct | 368 ms | 16508 KB | Output is correct |