Submission #915244

#TimeUsernameProblemLanguageResultExecution timeMemory
915244SmuggingSpunStove (JOI18_stove)C++14
100 / 100
21 ms2528 KiB
#include<bits/stdc++.h> #define taskname "stove" using namespace std; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if(fopen(taskname".inp", "r")){ freopen(taskname".inp", "r", stdin); } int n, k; cin >> n >> k; vector<int>t(n); for(int& x : t){ cin >> x; } priority_queue<int>pq; for(int i = 1; i < n; i++){ pq.push(t[i] - t[i - 1] - 1); } int ans = t[n - 1] - t[0] + 1; for(int i = 1; i < k; i++){ ans -= pq.top(); pq.pop(); } cout << ans; }

Compilation message (stderr)

stove.cpp: In function 'int main()':
stove.cpp:7:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |   freopen(taskname".inp", "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...