Submission #486852

#TimeUsernameProblemLanguageResultExecution timeMemory
486852TypeYippieStove (JOI18_stove)C++14
100 / 100
19 ms2036 KiB
#include <bits/stdc++.h> using namespace std; int main(){ int n, k, time[100005], interval[100005]; scanf("%d%d", &n, &k); for(int i = 0; i < n; i++){ scanf("%d", time+i); if(i > 0){ interval[i-1] = time[i]-time[i-1]-1; } } sort(interval, interval+n-1, greater<int>()); int ans = time[n-1]-time[0]+1; for(int i = 0; i < k-1; i++){ ans -= interval[i]; } printf("%d\n", ans); return 0; }

Compilation message (stderr)

stove.cpp: In function 'int main()':
stove.cpp:6:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 |  scanf("%d%d", &n, &k);
      |  ~~~~~^~~~~~~~~~~~~~~~
stove.cpp:8:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |   scanf("%d", time+i);
      |   ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...