제출 #557002

#제출 시각아이디문제언어결과실행 시간메모리
557002Ai7081Stove (JOI18_stove)C++17
100 / 100
27 ms2256 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; priority_queue<int> pq; int n, k, a[N], ans; int main() { scanf(" %d %d", &n, &k); for (int i=0; i<n; i++) scanf(" %d", &a[i]); for (int i=0; i<n-1; i++) { pq.push(a[i+1] - a[i] - 1); } ans = a[n-1] - a[0] + 1; while (--k) ans -= pq.top(), pq.pop(); printf("%d", ans); return 0; }

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

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:34: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     for (int i=0; i<n; i++) scanf(" %d", &a[i]);
      |                             ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...