Submission #241037

#TimeUsernameProblemLanguageResultExecution timeMemory
241037NONAMETimovi (COCI18_timovi)C++14
30 / 80
23 ms2304 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; 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...