Submission #204689

#TimeUsernameProblemLanguageResultExecution timeMemory
204689my99nStove (JOI18_stove)C++14
100 / 100
38 ms2292 KiB
#include<bits/stdc++.h> using namespace std; int t[100100]; priority_queue<int> heap; long long sum; int main(){ int n, k; scanf("%d %d", &n, &k); k--; for (int i = 0; i < n; i++) scanf("%d", &t[i]); for (int i = 1; i < n; i++) heap.push(t[i]-t[i-1]-1); sum = t[n-1] - t[0] + 1; while (k--) sum -= heap.top(), heap.pop(); printf("%lld", sum); 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); k--;
     ~~~~~^~~~~~~~~~~~~~~~~
stove.cpp:11:38: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for (int i = 0; i < n; i++) scanf("%d", &t[i]);
                                 ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...