Submission #281826

#TimeUsernameProblemLanguageResultExecution timeMemory
281826BeanZStove (JOI18_stove)C++14
100 / 100
32 ms3324 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define endl '\n' const int N = 1e5 + 5; const int mod = 1e9 + 7; ll a[100005]; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); if (fopen("VietCT.INP", "r")){ freopen("VietCT.INP", "r", stdin); freopen("VietCT.OUT", "w", stdout); } ll n, k; cin >> n >> k; for (int i = 1; i <= n; i++) cin >> a[i]; ll ans = a[n] - a[1] + 1; k--; priority_queue<ll> pq; for (int i = 2; i <= n; i++){ pq.push(a[i] - a[i - 1] - 1); } while (k){ ans -= pq.top(); pq.pop(); k--; } cout << ans; } /* */

Compilation message (stderr)

stove.cpp: In function 'int main()':
stove.cpp:14:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   14 |                 freopen("VietCT.INP", "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
stove.cpp:15:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   15 |                 freopen("VietCT.OUT", "w", stdout);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...