#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n, k, m;
cin >> n >> k >> m;
int a[n + 1];
memset(a, 0, sizeof(a));
for(int i = 1; i <= n; i++){
a[i] = (m >= k ? k : m);
m -= (m >= k ? k : m);
}
int val = m / ((n - 1) * k);
m %= ((n - 1) * k);
for(int i = 1; i < n; i++){
a[i] += ((val + 1) / 2) * k;
}
for(int i = n; i > 1; i--){
a[i] += (val / 2) * k;
}
if(val % 2 == 0){
for(int i = 2; i <= n; i++){
a[i] += (m >= k ? k : m);
m -= (m >= k ? k : m);
}
}
else{
for(int i = n - 1; i >= 1; i--){
a[i] += (m >= k ? k : m);
m -= (m >= k ? k : m);
}
}
for(int i = 1; i <= n; i++){
cout << a[i] << " ";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
2 |
Correct |
3 ms |
424 KB |
Output is correct |
3 |
Correct |
21 ms |
2424 KB |
Output is correct |
4 |
Correct |
17 ms |
2304 KB |
Output is correct |
5 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
6 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
7 |
Incorrect |
29 ms |
2936 KB |
Output isn't correct |
8 |
Incorrect |
18 ms |
2916 KB |
Output isn't correct |