제출 #348302

#제출 시각아이디문제언어결과실행 시간메모리
348302HalogenStove (JOI18_stove)C++14
20 / 100
2 ms364 KiB
#include <bits/stdc++.h> using namespace std; main() { int N, K; scanf("%d %d", &N, &K); int lst[N + 5]; lst[0] = 0; for (int i = 1; i <= N; i++) scanf("%d", &lst[i]); priority_queue<int> pq; for (int i = 0; i < N; i++) { pq.push(lst[i + 1] - lst[i] - 1); } int ans = lst[N] - lst[1] + 1; for (int i = 1; i < K; i++) { // printf("%d\n", ans); ans -= pq.top(); pq.pop(); } printf("%d", ans); }

컴파일 시 표준 에러 (stderr) 메시지

stove.cpp:5:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    5 | main() {
      |      ^
stove.cpp: In function 'int main()':
stove.cpp:6:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    6 |     int N, K; scanf("%d %d", &N, &K);
      |               ~~~~~^~~~~~~~~~~~~~~~~
stove.cpp:8:39: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    8 |     for (int i = 1; i <= N; i++) scanf("%d", &lst[i]);
      |                                  ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...