Submission #59949

#TimeUsernameProblemLanguageResultExecution timeMemory
59949gusfringStove (JOI18_stove)C++14
100 / 100
41 ms10304 KiB
#include <bits/stdc++.h> const int MAXN = 1e5 + 5; int t[MAXN], a[MAXN], N, K; int main(){ int N, K; scanf("%d %d", &N, &K); for(int i=0; i<N; ++i) scanf("%d", &t[i]); int res = t[N - 1] + 1 - t[0]; for(int i=0; i<N-1; ++i) a[i] = t[i + 1] - t[i] - 1; std::sort(a, a + N - 1, std::greater<int>()); for(int i=0; i<K-1; ++i) res -= a[i]; printf("%d",res); }

Compilation message (stderr)

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