답안 #967655

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
967655 2024-04-22T15:16:37 Z vjudge1 Stove (JOI18_stove) C++17
0 / 100
0 ms 348 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);
    if (n == k) return printf("0"), 0;
    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:15:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         scanf("%lld", &curr);
      |         ~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -