Submission #410715

#TimeUsernameProblemLanguageResultExecution timeMemory
410715snasibov05Timovi (COCI18_timovi)C++14
80 / 80
23 ms2116 KiB
#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 timeMemoryGrader output
Fetching results...