Submission #241039

#TimeUsernameProblemLanguageResultExecution timeMemory
241039NONAMETimovi (COCI18_timovi)C++14
80 / 80
22 ms2944 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; const int N = 2e5 + 500; ll n, k, m, res[N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> k >> m; if (m <= n * k) { for (int i = 0; i < n && m > 0; ++i) { res[i] += min(m, k); m -= min(m, k); } } else { for (int i = 0; i < n; ++i) { res[i] += min(m, k); m -= min(m, k); } ll t = m / ((n - 1) * k); ll ft = (t + 1) / 2, lst = (t / 2); res[0] += ft * k; res[n - 1] += lst * k; for (int i = 1; i < n - 1; ++i) res[i] += t * k; ll ost = m - t * (n - 1) * k; if (t & 1) { for (int i = 1; i < n && ost > 0; ++i) { res[i] += min(ost, k); ost -= min(ost, k); } } else { for (int i = n - 2; i >= 0 && ost > 0; --i) { res[i] += min(ost, k); ost -= min(ost, k); } } } for (int i = 0; i < n; ++i) cout << res[i] << " "; cout << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...