#include <iostream>
#include <vector>
using namespace std;
int main() {
int n, m, k; cin >> n >> k >> m;
vector<int> ans(n);
int y = m;
for (int i = 0; i < n && m > 0; ++i){
ans[i] = min(k, m);
m -= ans[i];
}
int x = m;
for (int i = 1; i < n-1 && m > 0; ++i){
ans[i] += k * (x / ((n-1) * k));
m -= k * (x / ((n-1) * k));
}
ans[0] += k * (((x / ((n-1) * k)) + 1) / 2);
ans[n-1] += k * ((x / ((n-1) * k)) / 2);
int full = (x / ((n-1) * k));
for (int i = 0; i < n; ++i) {
y -= ans[i];
}
if (full % 2){
for (int i = 1; i < n && y > 0; ++i){
ans[i] += min(y, k);
y -= min(y, k);
}
} else{
for (int i = n-2; i >= 0 && y > 0; --i){
ans[i] += min(y, k);
y -= min(y, k);
}
}
for (auto a : ans) cout << a << " ";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
20 ms |
1508 KB |
Output is correct |
4 |
Correct |
20 ms |
1412 KB |
Output is correct |
5 |
Correct |
1 ms |
296 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
22 ms |
2092 KB |
Output is correct |
8 |
Correct |
23 ms |
2116 KB |
Output is correct |