Submission #203525

#TimeUsernameProblemLanguageResultExecution timeMemory
203525SoGoodStove (JOI18_stove)C++14
100 / 100
79 ms2392 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define int ll const int N = 1e5 + 11; int n, k, a[N]; main() { cin>>n>>k; for (int i=1;i<=n;++i) cin>>a[i]; vector<int> v; for (int i = 2; i <= n; ++i) v.push_back(a[i]-a[i-1]-1); sort(v.begin(), v.end(),greater<int>()); int ans=0; --k; for (int i = k; i < v.size(); ++i) ans+=v[i]; cout<<ans+n; return 0; }

Compilation message (stderr)

stove.cpp:11:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
stove.cpp: In function 'int main()':
stove.cpp:20:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = k; i < v.size(); ++i) ans+=v[i];
                     ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...