Submission #136252

#TimeUsernameProblemLanguageResultExecution timeMemory
136252KLPPStove (JOI18_stove)C++14
100 / 100
30 ms2900 KiB
#include<bits/stdc++.h> using namespace std; typedef long long int lld; #define rep(i,a,b) for(int i=a;i<b;i++) int main(){ int n,k; scanf("%d %d",&n,&k); lld arr[n]; rep(i,0,n){ scanf("%lld",&arr[i]); } lld ans=arr[n-1]+1-arr[0]; lld diff[n-1]; rep(i,0,n-1)diff[i]=arr[i+1]-arr[i]-1; sort(diff,diff+(n-1)); reverse(diff,diff+(n-1)); rep(i,0,k-1){ ans-=diff[i]; } printf("%lld\n",ans); return 0; }

Compilation message (stderr)

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