Submission #348305

#TimeUsernameProblemLanguageResultExecution timeMemory
348305HalogenStove (JOI18_stove)C++14
100 / 100
31 ms3172 KiB
#include <bits/stdc++.h> using namespace std; #define int long long main() { int N, K; scanf("%lld %lld", &N, &K); int lst[1000005]; lst[0] = 0; for (int i = 1; i <= N; i++) scanf("%lld", &lst[i]); priority_queue<int> pq; for (int i = 1; i <= N; i++) { pq.push(lst[i + 1] - lst[i] - 1); } int ans = lst[N] - lst[1] + 1; for (int i = 1; i < K; i++) { // printf("%lld\n", ans); ans -= pq.top(); pq.pop(); } printf("%lld", ans); }

Compilation message (stderr)

stove.cpp:7:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    7 | main() {
      |      ^
stove.cpp: In function 'int main()':
stove.cpp:8:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    8 |     int N, K; scanf("%lld %lld", &N, &K);
      |               ~~~~~^~~~~~~~~~~~~~~~~~~~~
stove.cpp:10:39: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   10 |     for (int i = 1; i <= N; i++) scanf("%lld", &lst[i]);
      |                                  ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...