#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 |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
640 KB |
Output is correct |
3 |
Correct |
3 ms |
640 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1536 KB |
Output is correct |
2 |
Correct |
3 ms |
1408 KB |
Output is correct |
3 |
Correct |
3 ms |
1536 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
2176 KB |
Output is correct |
2 |
Correct |
5 ms |
2432 KB |
Output is correct |
3 |
Correct |
4 ms |
2304 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
3072 KB |
Output is correct |
2 |
Correct |
4 ms |
2816 KB |
Output is correct |
3 |
Correct |
5 ms |
2688 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
2668 KB |
Output is correct |
2 |
Correct |
5 ms |
2816 KB |
Output is correct |
3 |
Correct |
2 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
57 ms |
19196 KB |
Output is correct |
2 |
Correct |
64 ms |
20712 KB |
Output is correct |
3 |
Correct |
549 ms |
94812 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
143 ms |
38424 KB |
Output is correct |
2 |
Correct |
505 ms |
94624 KB |
Output is correct |
3 |
Correct |
147 ms |
41232 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
606 ms |
95532 KB |
Output is correct |
2 |
Correct |
6 ms |
2560 KB |
Output is correct |
3 |
Correct |
4 ms |
1664 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
618 ms |
96360 KB |
Output is correct |
2 |
Correct |
432 ms |
96440 KB |
Output is correct |
3 |
Correct |
456 ms |
96736 KB |
Output is correct |