Submission #1266697

#TimeUsernameProblemLanguageResultExecution timeMemory
1266697herominhsteveStove (JOI18_stove)C++20
100 / 100
14 ms1096 KiB
#include <bits/stdc++.h> int main(){ int n,K; int a[100'001],b[100'001]; scanf("%d %d",&n,&K); for (int i=0;i<n;i++){ int x; scanf("%d",&x); a[i] = x; } for (int i=1;i<n;i++){ b[i-1] = a[i] - (a[i-1]+1); } std::sort(b,b+n-1); int res = n; for (int i=0;i<n-K;i++){ res += b[i]; } printf("%d",res); }

Compilation message (stderr)

stove.cpp: In function 'int main()':
stove.cpp:6:8: 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:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     scanf("%d",&x);
      |     ~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...