Submission #559932

#TimeUsernameProblemLanguageResultExecution timeMemory
559932hibikiStove (JOI18_stove)C++11
100 / 100
20 ms1800 KiB
#include<bits/stdc++.h> using namespace std; #define pb push_back #define f first #define s second int n,k; vector<int> v; int main() { scanf("%d %d",&n,&k); int lst = 0, fi; scanf("%d",&lst); fi = lst; for(int i = 1; i < n; i++) { int a; scanf("%d",&a); v.pb(a - (lst + 1)); lst = a; } sort(v.begin(),v.end()); int all = lst + 1 - fi; for(int i = v.size() - 1, j = 0; i >= 0 && j < k - 1 ; i--, j++) all -= v[i]; printf("%d\n",all); return 0; }

Compilation message (stderr)

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