Submission #71439

#TimeUsernameProblemLanguageResultExecution timeMemory
71439win11905Stove (JOI18_stove)C++11
100 / 100
38 ms10208 KiB
#include <bits/stdc++.h> using namespace std; int n, k; int main() { scanf("%d %d", &n, &k); vector<int> V; int pv; scanf("%d", &pv); for(int i = 1, a; i < n; ++i) { scanf("%d", &a); V.emplace_back(a - pv - 1); pv = a; } sort(V.begin(), V.end()); int v = n-k; for(int i = 0; i < v; ++i) n += V[i]; printf("%d\n", n); }

Compilation message (stderr)

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