Submission #528481

#TimeUsernameProblemLanguageResultExecution timeMemory
528481georgerapeanuArt Exhibition (JOI18_art)C++11
0 / 100
1 ms332 KiB
#include <bits/stdc++.h> using namespace std; int main(){ int n, k; scanf("%d %d", &n, &k); vector<int> v(n, 0); sort(v.begin(), v.end()); for(auto &it:v){ scanf("%d", &it); } vector<int> stuff; for(int i = 1;i < n;i++){ stuff.push_back(v[i] - v[i - 1] - 1); } int ans = v.back() - v[0] + 1; sort(stuff.begin(), stuff.end()); reverse(stuff.begin(), stuff.end()); for(int i = 0;i < k - 1;i++){ ans -= max(0, stuff[i]); } printf("%d", ans); return 0; }

Compilation message (stderr)

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