제출 #66728

#제출 시각아이디문제언어결과실행 시간메모리
66728ege_eksiStove (JOI18_stove)C++14
100 / 100
37 ms1524 KiB
#include<iostream> #include<cstdio> #include<cstdlib> #include<queue> using namespace std; int main() { int n , k; scanf("%d %d",&n,&k); int *a = new int[n]; scanf("%d",&a[0]); priority_queue<int> pq; for(int i = 1 ; i < n ; i++) { scanf("%d",&a[i]); pq.push(a[i] -(a[i-1]+1)); } int ans = (a[n-1]+1) - a[0]; while(k > 1) { ans -= pq.top(); pq.pop(); k--; } printf("%d",ans); return 0; }

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

stove.cpp: In function 'int main()':
stove.cpp:11:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d",&n,&k);
  ~~~~~^~~~~~~~~~~~~~~
stove.cpp:15:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&a[0]);
  ~~~~~^~~~~~~~~~~~
stove.cpp:21:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&a[i]);
   ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...