Submission #241037

# Submission time Handle Problem Language Result Execution time Memory
241037 2020-06-22T09:49:01 Z NONAME Timovi (COCI18_timovi) C++14
30 / 80
23 ms 2304 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;
        
        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 Incorrect 5 ms 256 KB Output isn't correct
2 Incorrect 5 ms 384 KB Output isn't correct
3 Correct 18 ms 896 KB Output is correct
4 Correct 19 ms 768 KB Output is correct
5 Incorrect 5 ms 384 KB Output isn't correct
6 Correct 4 ms 384 KB Output is correct
7 Incorrect 23 ms 2280 KB Output isn't correct
8 Incorrect 19 ms 2304 KB Output isn't correct