Submission #110076

#TimeUsernameProblemLanguageResultExecution timeMemory
110076maruiiStove (JOI18_stove)C++14
100 / 100
31 ms2176 KiB
#include<bits/stdc++.h> using namespace std; int N, K; int A[100001], B[100001]; int main(){ scanf("%d%d",&N,&K); for(int i=0; i<N; ++i) scanf("%d",A+i); for(int i=0; i<N-1; ++i) B[i] = A[i+1]-A[i]; sort(B, B+N-1); int ans = accumulate(B, B+N-K, 0); printf("%d",ans+K); }

Compilation message (stderr)

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