Submission #52060

# Submission time Handle Problem Language Result Execution time Memory
52060 2018-06-23T14:17:00 Z someone_aa Popeala (CEOI16_popeala) C++17
17 / 100
2000 ms 79200 KB
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 4100;
int cnt[maxn][maxn], n, t, s;
int pref[55][maxn];
int points[maxn];
int prefpoints[maxn];
int dp[maxn][maxn];
bool matrix[maxn][maxn];

/*
n - contestants
t - test cases
s - subtasks
*/

int main() {
    cin>>n>>t>>s;

    for(int i=1;i<=t;i++) {
        cin>>points[i];
        prefpoints[i] = prefpoints[i-1] + points[i];
    }

    string code;
    for(int i=0;i<n;i++) {
        cin>>code;
        for(int j=1;j<=t;j++) {
            pref[i][j] = pref[i][j-1] + int(code[j-1]-'0');
        }
    }

    for(int i=1;i<=t;i++) {
        for(int j=1;j<=i;j++) {
            for(int k=0;k<n;k++) {
                if(pref[k][i] - pref[k][j-1] == (i-j+1)) {
                    cnt[j][i]++;
                }
            }
        }
    }

    memset(dp, -1, sizeof(dp));

    dp[0][0] = 0;

    for(int i=1;i<=t;i++) {
        for(int j=1;j<=s;j++) {
            dp[i][j] = INT_MAX;
            for(int x=0;x<i;x++) {
                if(dp[x][j-1] != -1) {
                    dp[i][j] = min(dp[i][j], dp[x][j-1] + (prefpoints[i] - prefpoints[x]) * cnt[x+1][i]);
                }
            }
            if(dp[i][j] == INT_MAX) dp[i][j] = -1;
        }
    }

    for(int i=1;i<=s;i++) {
        cout<<dp[t][i]<<"\n";
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 51 ms 66168 KB Output is correct
2 Correct 53 ms 66508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 81 ms 69044 KB Output is correct
2 Correct 82 ms 69096 KB Output is correct
3 Correct 78 ms 69096 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2065 ms 79200 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 51 ms 66168 KB Output is correct
2 Correct 53 ms 66508 KB Output is correct
3 Correct 81 ms 69044 KB Output is correct
4 Correct 82 ms 69096 KB Output is correct
5 Correct 78 ms 69096 KB Output is correct
6 Execution timed out 2065 ms 79200 KB Time limit exceeded
7 Halted 0 ms 0 KB -