Submission #516300

# Submission time Handle Problem Language Result Execution time Memory
516300 2022-01-21T04:17:20 Z Jomnoi Stove (JOI18_stove) C++17
100 / 100
30 ms 2352 KB
#include <bits/stdc++.h>
#define DEBUG 0
using namespace std;

const int N = 1e5 + 10;

int t[N];

int main() {
    int n, k;
    scanf(" %d %d", &n, &k);
    for(int i = 1; i <= n; i++) {
        scanf(" %d", &t[i]);
    }

    int ans = t[n] - t[1] + 1;
    priority_queue <int> pq;
    for(int i = 2; i <= n; i++) {
        pq.emplace(t[i] - t[i - 1] - 1);
    }

    while(!pq.empty() and --k) {
        ans -= pq.top();
        pq.pop();
    }
    cout << ans;
    return 0;
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     scanf(" %d %d", &n, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~~
stove.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |         scanf(" %d", &t[i]);
      |         ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 300 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 0 ms 296 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 260 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 300 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 0 ms 296 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 260 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 312 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 300 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 0 ms 296 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 260 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 312 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 17 ms 2352 KB Output is correct
17 Correct 13 ms 2252 KB Output is correct
18 Correct 13 ms 2296 KB Output is correct
19 Correct 14 ms 2216 KB Output is correct
20 Correct 18 ms 2208 KB Output is correct
21 Correct 22 ms 2236 KB Output is correct
22 Correct 30 ms 2224 KB Output is correct
23 Correct 23 ms 2292 KB Output is correct
24 Correct 30 ms 2184 KB Output is correct