Submission #42089

#TimeUsernameProblemLanguageResultExecution timeMemory
42089nonocutStove (JOI18_stove)C++14
100 / 100
33 ms3116 KiB
#include<bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; int n,k; int p[maxn]; int main() { int i,x,y; scanf("%d%d",&n,&k); for(i=0;i<n;i++) { scanf("%d",&x); if(i) p[i] = x-y-1; y = x; } sort(p,p+n); int ans = n; for(i=0;i<n-k+1;i++) ans += p[i]; printf("%d",ans); }

Compilation message (stderr)

stove.cpp: In function 'int main()':
stove.cpp:8:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&k);
                        ^
stove.cpp:10:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&x);
                       ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...