Submission #75103

#TimeUsernameProblemLanguageResultExecution timeMemory
75103bogdan10bosStove (JOI18_stove)C++14
100 / 100
39 ms10408 KiB
#include <bits/stdc++.h> using namespace std; //#define FILE_IO int N, K; int v[100005]; int t[100005]; int main() { #ifdef FILE_IO freopen("1.in", "r", stdin); freopen("1.out", "w", stdout); #endif scanf("%d", &N); scanf("%d", &K); for(int i = 1; i <= N; i++) scanf("%d", &v[i]); for(int i = 1; i < N; i++) t[i] = v[i + 1] - v[i] - 1; sort(t + 1, t + N); int ans = N; for(int i = 1; i <= N - K; i++) ans += t[i]; printf("%d\n", ans); return 0; }

Compilation message (stderr)

stove.cpp: In function 'int main()':
stove.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &N);
     ~~~~~^~~~~~~~~~
stove.cpp:19:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &K);
     ~~~~~^~~~~~~~~~
stove.cpp:21:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &v[i]);
         ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...