Submission #117634

#TimeUsernameProblemLanguageResultExecution timeMemory
117634wilwxkStove (JOI18_stove)C++14
100 / 100
31 ms2228 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN=1e5+5; priority_queue<int> pq; int v[MAXN]; int n, x; int resp; int main() { scanf("%d %d", &n, &x); for(int i=1; i<=n; i++) { scanf("%d", &v[i]); if(i!=1) pq.push(v[i]-v[i-1]-1); } resp=v[n]-v[1]+1; x--; while(x--) { if(pq.size()) { resp-=pq.top(); pq.pop(); } } printf("%d\n", resp); }

Compilation message (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, &x);
  ~~~~~^~~~~~~~~~~~~~~~~
stove.cpp:13:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &v[i]);
   ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...