답안 #121644

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
121644 2019-06-26T21:41:10 Z Leonardo_Paes Vođe (COCI17_vode) C++11
120 / 120
762 ms 96696 KB
#include <bits/stdc++.h>

using namespace std;

const int maxn = 5e3 + 10;

int vet[maxn], dp[maxn][maxn];

int main(){

    int n, m, k;

    cin >> n >> m >> k;

    m--;

    for(int i=0; i<n; i++){
        cin >> vet[i];
        dp[i][m] = vet[i]^1;
    }

    for(int j=m-1; j>=0; j--){
        for(int i=0; i<n; i++){
            int possible_answers = dp[(i+1)%n][j+1];
            int length = m-j;
            if(j+k<m){
                possible_answers -= dp[(i+1)%n][j+k+1];
                length = k;
            }
            if(possible_answers==0) dp[i][j] = dp[i][j+1];
            else if(possible_answers==length) dp[i][j] = 1 + dp[i][j+1];
            else dp[i][j] = vet[i] + dp[i][j+1];
        }
    }

    for(int i=0; i<n; i++){
        cout << dp[i][0] - dp[i][1] << " ";
    }
	cout << "\n";
    return 0;
}







# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 640 KB Output is correct
3 Correct 2 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1280 KB Output is correct
2 Correct 2 ms 768 KB Output is correct
3 Correct 3 ms 1408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1536 KB Output is correct
2 Correct 3 ms 1408 KB Output is correct
3 Correct 4 ms 1536 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2048 KB Output is correct
2 Correct 4 ms 2432 KB Output is correct
3 Correct 4 ms 2304 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 3072 KB Output is correct
2 Correct 5 ms 2944 KB Output is correct
3 Correct 4 ms 2688 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2688 KB Output is correct
2 Correct 4 ms 2816 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 54 ms 19192 KB Output is correct
2 Correct 57 ms 20728 KB Output is correct
3 Correct 546 ms 94856 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 137 ms 38384 KB Output is correct
2 Correct 506 ms 94580 KB Output is correct
3 Correct 153 ms 41052 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 762 ms 95632 KB Output is correct
2 Correct 7 ms 2532 KB Output is correct
3 Correct 5 ms 1664 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 587 ms 96276 KB Output is correct
2 Correct 435 ms 96436 KB Output is correct
3 Correct 498 ms 96696 KB Output is correct