Submission #143038

# Submission time Handle Problem Language Result Execution time Memory
143038 2019-08-12T16:43:18 Z Azert Timovi (COCI18_timovi) C++14
80 / 80
21 ms 2168 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 2e5 + 5;
int n, k, m;
int res[N];

int main() {
    scanf("%d%d%d", &n, &k, &m);

    int time = m / k;
    int cycle = time / (n - 1);
    for (int i = 2; i < n; i++) res[i] += k * cycle;
    res[1] += ((cycle + 1) / 2) * k;
    res[n] += (cycle / 2) * k;

    m -= cycle * (n - 1) * k;
    if (cycle % 2 == 1) {
        for (int i = n; m != 0; i--) {
            res[i] += min(k, m);
            m -= min(k, m);
        }
    }
    else {
        for (int i = 1; m != 0; i++) {
            res[i] += min(k, m);
            m -= min(k, m);
        }
    }

    for (int i = 1; i <= n; i++) printf("%d ", res[i]);
}

Compilation message

timovi.cpp: In function 'int main()':
timovi.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d", &n, &k, &m);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 20 ms 1528 KB Output is correct
4 Correct 18 ms 1528 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 21 ms 2168 KB Output is correct
8 Correct 21 ms 2168 KB Output is correct