Submission #239798

# Submission time Handle Problem Language Result Execution time Memory
239798 2020-06-17T10:05:38 Z VEGAnn Timovi (COCI18_timovi) C++14
80 / 80
23 ms 2936 KB
#include <bits/stdc++.h>
#define PB push_back
#define sz(x) ((int)x.size())
using namespace std;
typedef long double ld;
typedef long long ll;
const int N = 200100;
const int M = 110;
const int K = 110;
const int MX = 210;
const int oo = 2e9;
ll n, k, m, ans[N];

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);

#ifdef _LOCAL
    freopen("in.txt","r",stdin);
#endif // _LOCAL

    cin >> n >> k >> m;

    ll val = m / ((n - 1) * k);

    for (int i = 1; i < n - 1; i++)
        ans[i] = val * k;

    ans[n - 1] = (val / 2) * k;
    ans[0] = (val - ans[n - 1] / k) * k;

    m %= (n - 1) * k;

    if (val & 1){
        for (int i = n - 1; i >= 0 && m >= 0; i--){
            ll ost = min(m, k);
            ans[i] += ost;
            m -= ost;
        }
    } else {
        for (int i = 0; i < n && m >= 0; i++){
            ll ost = min(m, k);
            ans[i] += ost;
            m -= ost;
        }
    }

    for (int i = 0; i < n; i++)
        cout << ans[i] << " ";

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 20 ms 2304 KB Output is correct
4 Correct 20 ms 2304 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 23 ms 2936 KB Output is correct
8 Correct 22 ms 2936 KB Output is correct