Submission #967654

# Submission time Handle Problem Language Result Execution time Memory
967654 2024-04-22T15:15:21 Z vjudge1 Stove (JOI18_stove) C++17
0 / 100
1 ms 344 KB
#include <iostream>
#include <queue>

using namespace std;

long long ans = 1ll;

int main()
{
    priority_queue<long long> pq;
    int n, k;
    long long pre, curr; scanf("%d %d %lld", &n, &k, &pre);
    for (int i = 1;i < n;i++){
        scanf("%lld", &curr);
        pq.push(curr-pre+1);
        ans += curr-pre+1;
        pre = curr;
    }
    while (--k){
        ans -= pq.top();
        pq.pop();
    }
    printf("%lld", ans);
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:12:31: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     long long pre, curr; scanf("%d %d %lld", &n, &k, &pre);
      |                          ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
stove.cpp:14:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |         scanf("%lld", &curr);
      |         ~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -