Submission #219807

#TimeUsernameProblemLanguageResultExecution timeMemory
219807NightlightStove (JOI18_stove)C++14
0 / 100
5 ms384 KiB
#include <bits/stdc++.h> using namespace std; int N, K; int best[100005]; int main() { scanf("%d %d", &N, &K); int last, now, pertamax, terakhir; scanf("%d", &pertamax); last = pertamax; for(int i = 2; i < N; i++) { scanf("%d", &now); best[i - 1] = now - last - 1; last = now; } scanf("%d", &terakhir); best[N - 1] = terakhir - last - 1; sort(best + 1, best + N + 1, greater<int>()); int ans = terakhir - pertamax + 1; for(int i = 1; i < K; i++) { ans -= best[i]; } printf("%d", ans); }

Compilation message (stderr)

stove.cpp: In function 'int main()':
stove.cpp:8:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &N, &K);
   ~~~~~^~~~~~~~~~~~~~~~~
stove.cpp:10:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &pertamax);
   ~~~~~^~~~~~~~~~~~~~~~~
stove.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &now);
     ~~~~~^~~~~~~~~~~~
stove.cpp:17:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &terakhir);
   ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...