Submission #94606

# Submission time Handle Problem Language Result Execution time Memory
94606 2019-01-21T15:56:50 Z ahmedie404 Timovi (COCI18_timovi) C++14
50 / 80
1000 ms 1528 KB
#include <iostream>

using namespace std;

int ts[200000+9];
int n;
int k, m;
int main(){

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

    for(int i=0;i<n;i++) ts[i]=0;

    int idx=0;
    bool forw=true;
    while(true){

        if(idx >= n){
            idx = n-2;
            forw = false;
        }

        if(idx < 0){
            idx = 1;
            forw = true;
        }

        if(k > 0 && m > 0){

            ts[idx] += ( m >= k ) ? k : m;
            m-=( m >= k ) ? k : m;
            idx += forw == true ? 1 : -1;

        } else break;

    }

    for(int i=0;i<n;i++){
        printf("%d ", ts[i]);
    }



    return 0;
}

Compilation message

timovi.cpp: In function 'int main()':
timovi.cpp:10: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 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 16 ms 1528 KB Output is correct
4 Correct 16 ms 1528 KB Output is correct
5 Execution timed out 1075 ms 376 KB Time limit exceeded
6 Correct 917 ms 376 KB Output is correct
7 Execution timed out 1073 ms 1016 KB Time limit exceeded
8 Execution timed out 1072 ms 1144 KB Time limit exceeded