Submission #204066

#TimeUsernameProblemLanguageResultExecution timeMemory
204066KastandaStove (JOI18_stove)C++11
100 / 100
65 ms6396 KiB
// In The Name Of The Queen #include<bits/stdc++.h> using namespace std; const int N = 100005; int n, k, tot, A[N]; int main() { scanf("%d%d", &n, &k); for (int i = 1; i <= n; i ++) scanf("%d", &A[i]); tot += n; multiset < int > ST; for (int i = 1; i < n; i ++) ST.insert(A[i + 1] - A[i] - 1); for (int i = 1; i <= n - k; i ++) { int a = * ST.begin(); ST.erase(ST.begin()); tot += a; } return !printf("%d\n", tot); }

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