Submission #98245

# Submission time Handle Problem Language Result Execution time Memory
98245 2019-02-21T16:21:13 Z dalgerok Timovi (COCI18_timovi) C++17
80 / 80
30 ms 2944 KB
#include<bits/stdc++.h>
#define int long long
using namespace std;




signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n, k, m;
    cin >> n >> k >> m;
    int a[n + 1];
    memset(a, 0, sizeof(a));
    for(int i = 1; i <= n; i++){
        a[i] = (m >= k ? k : m);
        m -= (m >= k ? k : m);
    }
    int val = m / ((n - 1) * k);
    m %= ((n - 1) * k);
    for(int i = 1; i < n; i++){
        a[i] += ((val + 1) / 2) * k;
    }
    for(int i = n; i > 1; i--){
        a[i] += (val / 2) * k;
    }
    if(val % 2 == 1){
        for(int i = 2; i <= n; i++){
            a[i] += (m >= k ? k : m);
            m -= (m >= k ? k : m);
        }
    }
    else{
        for(int i = n - 1; i >= 1; i--){
            a[i] += (m >= k ? k : m);
            m -= (m >= k ? k : m);
        }
    }
    for(int i = 1; i <= n; i++){
        cout << a[i] << " ";
    }
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 30 ms 2292 KB Output is correct
4 Correct 18 ms 2432 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 19 ms 2944 KB Output is correct
8 Correct 19 ms 2944 KB Output is correct