Submission #557016

#TimeUsernameProblemLanguageResultExecution timeMemory
557016Ai7081Stove (JOI18_stove)C++17
100 / 100
33 ms1872 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; priority_queue<int> pq; int n, k, a, b, ans; int main() { scanf(" %d %d", &n, &k); scanf(" %d", &b); ans = 1-b; while (--n) { scanf(" %d", &a); pq.push(a - b - 1); b = a; } ans += b; while (--k) ans -= pq.top(), pq.pop(); printf("%d", ans); 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]
   10 |     scanf(" %d %d", &n, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~~
stove.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     scanf(" %d", &b);
      |     ~~~~~^~~~~~~~~~~
stove.cpp:14:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |         scanf(" %d", &a);
      |         ~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...