Submission #153342

#TimeUsernameProblemLanguageResultExecution timeMemory
153342mhy908Stove (JOI18_stove)C++14
0 / 100
2 ms256 KiB
#include <bits/stdc++.h> int n,k,t[100010],arr[100010],ans,i; main() { scanf("%d%d",&n,&k); for(i=1;i<=n;i++)scanf("%d", &t[i]); for(i=2;i<=n;i++)arr[i-1]=t[i]-t[i-1]-1; std::sort(arr+1, arr+n); for(i=1;i<=n-k-1;i++)ans+=arr[i]; printf("%d", ans+n); }

Compilation message (stderr)

stove.cpp:3:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
stove.cpp: In function 'int main()':
stove.cpp:5:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&k);
     ~~~~~^~~~~~~~~~~~~~
stove.cpp:6:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(i=1;i<=n;i++)scanf("%d", &t[i]);
                      ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...