Submission #335636

#TimeUsernameProblemLanguageResultExecution timeMemory
335636JoshcStove (JOI18_stove)C++11
100 / 100
25 ms1768 KiB
#include <cstdio> #include <vector> #include <algorithm> using namespace std; int main() { int n, k, x, y; scanf("%d%d", &n, &k); vector<int> v; for (int i=0; i<n; i++) { scanf("%d", &y); if (i) v.push_back(y-x-1); x = y; } int ans = n; sort(v.begin(), v.end()); for (int i=0; i<n-k; i++) ans += v[i]; printf("%d\n", ans); }

Compilation message (stderr)

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