Submission #134172

#TimeUsernameProblemLanguageResultExecution timeMemory
134172BoxworldStove (JOI18_stove)C++14
100 / 100
28 ms1784 KiB
#include <bits/stdc++.h> using namespace std; int d[100100]; int main(){ int n,k,l,x,ans=0,tmp=0; scanf("%d%d%d",&n,&k,&l); for (int i=0;i<n-1;i++){ scanf("%d",&x); d[tmp]=x-l-1; if (d[tmp]!=0)tmp++; l=x; } sort(d,d+tmp); for (int i=0;i<max(0,tmp-k+1);i++)ans+=d[i]; printf("%d\n",n+ans); }

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%d",&n,&k,&l);
  ~~~~~^~~~~~~~~~~~~~~~~~~
stove.cpp:8:8: 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...