# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
241039 |
2020-06-22T09:52:09 Z |
NONAME |
Timovi (COCI18_timovi) |
C++14 |
|
22 ms |
2944 KB |
#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 time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
22 ms |
896 KB |
Output is correct |
4 |
Correct |
20 ms |
768 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
4 ms |
384 KB |
Output is correct |
7 |
Correct |
21 ms |
2944 KB |
Output is correct |
8 |
Correct |
22 ms |
2936 KB |
Output is correct |