Submission #83342

# Submission time Handle Problem Language Result Execution time Memory
83342 2018-11-07T08:20:22 Z charlies_moo Rasvjeta (COCI17_rasvjeta) C++
50 / 50
3 ms 528 KB
# include <iostream>
# include <fstream>
using namespace std;

int main(){
    istream &fin = cin;
    ostream &fout = cout;
    int n, m, k, r, mi, sum, i, id;
    fin >> n >> m >> k;
    r = 1;
    sum = 0;
    id = 0;
    for(i = 1; i <= m; i ++){
        fin >> mi;
        if(r < mi - k){
            sum += (((mi - k - 1) - r) + 1 + k * 2) / (k * 2 + 1);
        }
        r = mi + k + 1;
    }
    if(n >= r){
        sum += (n - r + 1 + k * 2) / (k * 2 + 1);
    }
    fout << sum << endl;
    return 0;
}


Compilation message

rasjveta.cpp: In function 'int main()':
rasjveta.cpp:8:33: warning: variable 'id' set but not used [-Wunused-but-set-variable]
     int n, m, k, r, mi, sum, i, id;
                                 ^~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 400 KB Output is correct
4 Correct 3 ms 448 KB Output is correct
5 Correct 2 ms 528 KB Output is correct
6 Correct 2 ms 528 KB Output is correct
7 Correct 2 ms 528 KB Output is correct
8 Correct 2 ms 528 KB Output is correct
9 Correct 2 ms 528 KB Output is correct
10 Correct 2 ms 528 KB Output is correct