Submission #202920

# Submission time Handle Problem Language Result Execution time Memory
202920 2020-02-18T16:54:52 Z uzumix Stove (JOI18_stove) C++14
100 / 100
36 ms 2424 KB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n , k;

    cin >> n>> k;

    int a[n];

    for(int i = 0; i < n ; i++)
        cin >> a[i];

    sort(a,a+n);

    int ukupnoVreme = a[n-1] - a[0] + 1;

    vector<int> pauze;

    for(int i = 1 ; i < n ; i++)
    {
        int tmp = a[i] - a[i-1] - 1;

        if(tmp > 0)
            pauze.push_back(tmp);
    }

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



    for(int i = 0 ; i < pauze.size() && i<k-1; i++)
    {
        ukupnoVreme -= pauze[i];
    }

    cout << ukupnoVreme;


    return 0;
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:37:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0 ; i < pauze.size() && i<k-1; i++)
                     ~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 6 ms 380 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 6 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 6 ms 424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 380 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 6 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 6 ms 424 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 6 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 6 ms 376 KB Output is correct
14 Correct 7 ms 376 KB Output is correct
15 Correct 6 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 380 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 6 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 6 ms 424 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 6 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 6 ms 376 KB Output is correct
14 Correct 7 ms 376 KB Output is correct
15 Correct 6 ms 376 KB Output is correct
16 Correct 30 ms 2424 KB Output is correct
17 Correct 30 ms 2424 KB Output is correct
18 Correct 31 ms 2296 KB Output is correct
19 Correct 33 ms 2424 KB Output is correct
20 Correct 35 ms 2420 KB Output is correct
21 Correct 29 ms 2296 KB Output is correct
22 Correct 36 ms 2296 KB Output is correct
23 Correct 30 ms 2332 KB Output is correct
24 Correct 30 ms 2424 KB Output is correct