답안 #52061

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
52061 2018-06-23T14:25:23 Z someone_aa 조교 (CEOI16_popeala) C++17
0 / 100
253 ms 78924 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 j=1;j<=t;j++) {
        for(int i=1;i<=s;i++) {
            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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 49 ms 66168 KB Output is correct
2 Incorrect 50 ms 66536 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 65 ms 69020 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 253 ms 78924 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 49 ms 66168 KB Output is correct
2 Incorrect 50 ms 66536 KB Output isn't correct