# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
410715 | snasibov05 | Timovi (COCI18_timovi) | C++14 | 23 ms | 2116 KiB |
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 <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;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |