Submission #734753

# Submission time Handle Problem Language Result Execution time Memory
734753 2023-05-03T04:09:58 Z vjudge1 Timovi (COCI18_timovi) C++17
80 / 80
496 ms 13816 KB
#include <bits/stdc++.h>
#define B begin()
#define E end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define eb emplace_back
#define ll long long
#define ui unsigned int
#define ull unsigned long long
#define sts stable_sort
using namespace std;

const int MAXN = 1e6 + 4;
const int MOD = 1e9 + 7;

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

    ll n, k, m; cin >> n >> k >> m;
    map<ll, ll> ma;

    if(n * k >= m){
        for(ll i = 0; i < n; i++){
            if(m >= k){
                ma[i] += k;
                m -= k;
            }else if(m > 0){
                ma[i] += m;
                m = 0;
            }
        }
        for(ll i = 0; i < n; i++){
            cout << ma[i] << " ";
        }cout << "\n";
        return 0;
    }

    m -= n * k;
    ll izq = 0, der = 0, rest = (n - 1) * k;
    bool a = 0;

    while(m >= rest){
        m -= rest;
        if(a == 0){
            der += k;
            a = 1;
        }else{
            izq += k;
            a = 0;
        }
    }

    if(a){
        for(ll i = 1; m > 0;){
            if(m >= k){
                ma[i] += k;
                m -= k;
            }else{
                ma[i] += m;
                m = 0;
            }
            if(i == n - 1 && a){
                a = 0;
            }else if(i == 0 && !a){
                a = 1;
            }
            if(a)i++;
            else i--;
        }
    }else{
        for(ll i = n - 2; m > 0;){
            if(m >= k){
                ma[i] += k;
                m -= k;
            }else{
                ma[i] += m;
                m = 0;
            }
            if(i == n - 1 && a){
                a = 0;
            }else if(i == 0 && !a){
                a = 1;
            }
            if(a)i++;
            else i--;
        }
    }

    for(ll i = 0; i < n; i++){
        if(i <= n - 2){
            ma[i] += der;
        }
        if(i >= 1){
            ma[i] += izq;
        }

        cout << ma[i] + k << " ";
    }cout << "\n";

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 63 ms 13124 KB Output is correct
4 Correct 57 ms 13112 KB Output is correct
5 Correct 113 ms 296 KB Output is correct
6 Correct 496 ms 300 KB Output is correct
7 Correct 114 ms 13776 KB Output is correct
8 Correct 109 ms 13816 KB Output is correct