Submission #252616

#TimeUsernameProblemLanguageResultExecution timeMemory
252616ChrisTStove (JOI18_stove)C++17
100 / 100
36 ms2048 KiB
#include<bits/stdc++.h> using namespace std; int main () { int n,k; scanf("%d %d", &n, &k); vector<int> v(n); for (auto &au : v) scanf("%d", &au); int ans = v[n-1] - v[0] + 1; vector<int> go(n-1); for (int i = 0; i + 1 < n; i++) go[i] = v[i+1] - v[i]; sort(go.rbegin(),go.rend()); for (int i = 0; i + 1 < k; i++) ans -= go[i] - 1; printf ("%d\n",ans); return 0; }

Compilation message (stderr)

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