제출 #539692

#제출 시각아이디문제언어결과실행 시간메모리
539692krit3379Stove (JOI18_stove)C++17
100 / 100
38 ms2228 KiB
#include<bits/stdc++.h> using namespace std; #define N 100005 int t[N]; priority_queue<int> q; int main(){ int n,k,i,ans; scanf("%d %d",&n,&k); ans=n; for(i=1;i<=n;i++){ scanf("%d",&t[i]); if(i>1)q.push(t[i]-t[i-1]-1); } while(!q.empty()&&--k)q.pop(); while(!q.empty())ans+=q.top(),q.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:13:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |         scanf("%d",&t[i]);
      |         ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...