Submission #556998

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

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

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

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |     scanf(" %d %d", &n, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~~
stove.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     scanf(" %d", &b);
      |     ~~~~~^~~~~~~~~~~
stove.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |         scanf(" %d", &a);
      |         ~~~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 1 ms 296 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Incorrect 1 ms 296 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 1 ms 296 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Incorrect 1 ms 296 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 1 ms 296 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Incorrect 1 ms 296 KB Output isn't correct
10 Halted 0 ms 0 KB -