Submission #127206

#TimeUsernameProblemLanguageResultExecution timeMemory
127206hungcungStove (JOI18_stove)C++14
100 / 100
27 ms1144 KiB
#include<bits/stdc++.h> using namespace std; int n,k,a[100005],res[100005],dem,ans; int main(){ scanf("%d %d",&n,&k); for(int i=0;i<n;i++){ scanf("%d",&a[i]); if(i>=1){ res[dem]=a[i]-a[i-1]; dem++; } } sort(res,res+dem); ans=k; for(int i=0;i<n-k;i++){ ans+=res[i]; } printf("%d",ans); }

Compilation message (stderr)

stove.cpp: In function 'int main()':
stove.cpp:5: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:7: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...