Submission #967654

#TimeUsernameProblemLanguageResultExecution timeMemory
967654vjudge1Stove (JOI18_stove)C++17
0 / 100
1 ms344 KiB
#include <iostream> #include <queue> using namespace std; long long ans = 1ll; int main() { priority_queue<long long> pq; int n, k; long long pre, curr; scanf("%d %d %lld", &n, &k, &pre); for (int i = 1;i < n;i++){ scanf("%lld", &curr); pq.push(curr-pre+1); ans += curr-pre+1; pre = curr; } while (--k){ ans -= pq.top(); pq.pop(); } printf("%lld", ans); }

Compilation message (stderr)

stove.cpp: In function 'int main()':
stove.cpp:12:31: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     long long pre, curr; scanf("%d %d %lld", &n, &k, &pre);
      |                          ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
stove.cpp:14:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |         scanf("%lld", &curr);
      |         ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...