Submission #30663

# Submission time Handle Problem Language Result Execution time Memory
30663 2017-07-26T03:21:33 Z jenkhai Popeala (CEOI16_popeala) C++14
17 / 100
2000 ms 11848 KB
#include <bits/stdc++.h>
using namespace std;
const int MAXT = 2e4+10;
const int MAXN = 50+10;
const int MAXS = 50+10;
const int INF = 2e9+10;
int N, T, S;
int val[MAXT], valp[MAXT];
int dp[MAXT][MAXS];
vector<string> res;
int pf[MAXN][MAXT];

int score(int l, int r) {
    int subtask_score = valp[r] - valp[l-1];
    int ret = 0;        
    for(int i=1;i<=N;i++) {
        if(pf[i][r] - pf[i][l-1] == (r-l+1)) ret += subtask_score;
    }
    //printf("%d %d per subtask:%d, total=%d\n", l, r, subtask_score, ret);
    return ret;
}

int solve(int i, int k) {
    if(k==0 && i>0) return INF;
    if(k>i) return INF;
    if(i==0 && k==0) return 0;
    if(dp[i][k] != -1) return dp[i][k];
    dp[i][k] = INF;
    for(int j=1;j<=i;j++) {
        dp[i][k] = min(dp[i][k], solve(j-1, k-1) + score(j, i));
    }
    return dp[i][k];

}

int main() {
    ios::sync_with_stdio(false);
    cin >> N >> T >> S;
    for(int i=1;i<=T;i++) {
        cin >> val[i];
        valp[i] = valp[i-1] + val[i];
    }
    res.assign(N+1, ""); 
    for(int i=1;i<=N;i++) {
        cin >> res[i];
        for(int j=1;j<=T;j++) {
            pf[i][j] = pf[i][j-1] + (res[i][j-1]=='1');
        } 
    }

    for(int k=1;k<=S;k++) {
        for(int i=k;i<=T;i++) {
            dp[i][k] = -1;
        }
    }

    for(int k=1;k<=S;k++) {
        printf("%d\n", solve(T, k));
    } 
    
    
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 11716 KB Output is correct
2 Correct 0 ms 11716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 493 ms 11716 KB Output is correct
2 Correct 483 ms 11716 KB Output is correct
3 Correct 546 ms 11716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2000 ms 11848 KB Execution timed out
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 11716 KB Output is correct
2 Correct 0 ms 11716 KB Output is correct
3 Correct 493 ms 11716 KB Output is correct
4 Correct 483 ms 11716 KB Output is correct
5 Correct 546 ms 11716 KB Output is correct
6 Execution timed out 2000 ms 11848 KB Execution timed out
7 Halted 0 ms 0 KB -