Submission #557016

# Submission time Handle Problem Language Result Execution time Memory
557016 2022-05-04T14:42:24 Z Ai7081 Stove (JOI18_stove) C++17
100 / 100
33 ms 1872 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 1e5 + 5;

priority_queue<int> pq;
int n, k, a, b, ans;

int main() {
    scanf(" %d %d", &n, &k);
    scanf(" %d", &b);
    ans = 1-b;
    while (--n) {
        scanf(" %d", &a);
        pq.push(a - b - 1);
        b = a;
    }
    ans += b;
    while (--k) ans -= pq.top(), pq.pop();
    printf("%d", ans);
    return 0;
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     scanf(" %d %d", &n, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~~
stove.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     scanf(" %d", &b);
      |     ~~~~~^~~~~~~~~~~
stove.cpp:14:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |         scanf(" %d", &a);
      |         ~~~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 2 ms 312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 2 ms 312 KB Output is correct
16 Correct 13 ms 1744 KB Output is correct
17 Correct 14 ms 1832 KB Output is correct
18 Correct 14 ms 1872 KB Output is correct
19 Correct 21 ms 1744 KB Output is correct
20 Correct 23 ms 1796 KB Output is correct
21 Correct 26 ms 1728 KB Output is correct
22 Correct 33 ms 1752 KB Output is correct
23 Correct 25 ms 1744 KB Output is correct
24 Correct 24 ms 1744 KB Output is correct