Submission #121940

#TimeUsernameProblemLanguageResultExecution timeMemory
121940DodgeBallManStove (JOI18_stove)C++14
100 / 100
24 ms1916 KiB
#include <bits/stdc++.h> using namespace std; int n, k, ans, pv; vector<int> v; int main() { scanf("%d %d",&n,&k); scanf("%d",&pv); for( int i = 2, t ; i <= n ; i++ ) { scanf("%d",&t); v.emplace_back( t - pv - 1 ); pv = t; } sort( v.begin(), v.end() ); for( int i = 0 ; i < n - k ; i++ ) ans += v[i]; printf("%d",ans + n); return 0; }

Compilation message (stderr)

stove.cpp: In function 'int main()':
stove.cpp:10: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:11:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&pv);
     ~~~~~^~~~~~~~~~
stove.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&t);
         ~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...