Submission #525902

#TimeUsernameProblemLanguageResultExecution timeMemory
525902buidangnguyen05Stove (JOI18_stove)C++14
100 / 100
17 ms1100 KiB
/* input */ #include<bits/stdc++.h> using namespace std; typedef long long ll; const int N = 1e5 + 10; int a[N], b[N]; signed main() { cin.tie(0)->sync_with_stdio(0); if (fopen("task.inp", "r")) { freopen("task.inp", "r", stdin); freopen("task.out", "w", stdout); } int n, k; cin >> n >> k; --k; for (int i = 1; i <= n; ++i) cin >> a[i]; for (int i = 1; i < n; ++i) b[i] = a[i + 1] - a[i] - 1; int res = a[n] - a[1] + 1; sort(b + 1, b + n, greater<int>()); for (int i = 1; i <= k; ++i) res -= b[i]; cout << res << "\n"; }

Compilation message (stderr)

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