This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e3 + 10;
int vet[maxn], dp[maxn][maxn];
int main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
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;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |