Submission #711410

# Submission time Handle Problem Language Result Execution time Memory
711410 2023-03-16T21:09:39 Z thimote75 Stove (JOI18_stove) C++14
0 / 100
1 ms 300 KB
#include <bits/stdc++.h>

using namespace std;

#define num long long

int main () {
    int nbNodes, nbVal;
    cin >> nbNodes >> nbVal;
    nbVal --;

    vector<num> deltas;

    int last = 0;

    for (int i = 0; i < nbNodes; i ++) {
        int curr; cin >> curr;
        if (last != 0) deltas.push_back(curr - last - 1);

        last = curr;
        deltas.push_back(1);
    }

    sort(deltas.rbegin(), deltas.rend());

    num answer = 0;
    for (int i = nbVal; i < deltas.size(); i ++)
        answer += deltas[i];
    cout << answer;
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:28:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |     for (int i = nbVal; i < deltas.size(); i ++)
      |                         ~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Incorrect 1 ms 296 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Incorrect 1 ms 296 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Incorrect 1 ms 296 KB Output isn't correct
6 Halted 0 ms 0 KB -