Submission #1179614

#TimeUsernameProblemLanguageResultExecution timeMemory
1179614pythontestStove (JOI18_stove)C++20
100 / 100
15 ms964 KiB
#include <iostream> #include <algorithm> #include <vector> using namespace std; int main() { vector<int> vals; int n,k; scanf("%d %d",&n,&k); int last=-1; for(int i=0;i<n;i++){ int a; scanf("%d",&a); if(last!=-1){ vals.push_back(a-last); } last=a+1; } sort(vals.begin(),vals.end()); long long res=n; for(int i=0;i<n-k;i++){ res+=vals[i]; } printf("%lld",res); return 0; }

Compilation message (stderr)

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