Submission #992554

#TimeUsernameProblemLanguageResultExecution timeMemory
992554voiStove (JOI18_stove)C++17
100 / 100
18 ms2004 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int ar = 2e5+2; const ll mod = 1e9+7; const int oo = 1e9; int n, k, a[2]; signed main() { ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0); #define task "stove" if(fopen(task".inp", "r")) { freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } cin >> n >> k; int bit = 0; vector <int> v; for(int i = 1; i <= n; ++i) { cin >> a[bit]; if(i > 1) v.push_back(a[bit] - a[bit ^ 1] - 1); bit ^= 1; } sort(v.begin(), v.end()); int res = n; for(int i = 0; i < n - k; ++i) res += v[i]; cout << res; }

Compilation message (stderr)

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