# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
241037 | NONAME | Timovi (COCI18_timovi) | C++14 | 23 ms | 2304 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 <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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |