Submission #503587

# Submission time Handle Problem Language Result Execution time Memory
503587 2022-01-08T11:27:13 Z gaspar Stove (JOI18_stove) C++14
100 / 100
54 ms 2172 KB
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ifstream fin("date.in");
ofstream fout("date.out");
int n, k, v[100005];
vector <int> s;

int main() {
    cin >> n >> k;
    int rez = n, c = 1;
    for (int i = 1; i <= n; ++i) {
        cin >> v[i];
        if (i > 1 && v[i - 1] + 1 < v[i]) {
            s.push_back(v[i] - v[i - 1] - 1);
            ++c;
        }
    }
    sort(s.begin(), s.end());
    for (int i = 0; i < s.size(); ++i) {
        if (c > k) {
            --c;
            rez += s[i];
        }
    }
    cout << rez;
    return 0;
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:20:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     for (int i = 0; i < s.size(); ++i) {
      |                     ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 308 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 308 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 2 ms 332 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
13 Correct 2 ms 356 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 3 ms 320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 308 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 2 ms 332 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
13 Correct 2 ms 356 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 3 ms 320 KB Output is correct
16 Correct 48 ms 2116 KB Output is correct
17 Correct 52 ms 2088 KB Output is correct
18 Correct 43 ms 2108 KB Output is correct
19 Correct 43 ms 2108 KB Output is correct
20 Correct 46 ms 2172 KB Output is correct
21 Correct 54 ms 2096 KB Output is correct
22 Correct 47 ms 2112 KB Output is correct
23 Correct 43 ms 2108 KB Output is correct
24 Correct 43 ms 2096 KB Output is correct