Submission #391507

#TimeUsernameProblemLanguageResultExecution timeMemory
391507giorgikobStove (JOI18_stove)C++14
100 / 100
25 ms2380 KiB
#include<bits/stdc++.h> #define ll long long #define ff first #define ss second #define pb push_back using namespace std; const int N = 4e5+5, mod = 3; int n,k; vector<int>v; int A[N]; ll answer; inline void test_case(){ cin >> n >> k; for(int i = 1; i <= n; i++){ cin >> A[i]; } for(int i = 1; i < n; i++){ v.pb(A[i+1]-A[i]-1); } sort(v.begin(),v.end()); for(int i = 0; i < n-k; i++){ answer += v[i]; } cout << answer+n << endl; } main(){ ios::sync_with_stdio(0); int T = 1; //cin >> T; while(T--){ test_case(); } }

Compilation message (stderr)

stove.cpp:35:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   35 |  main(){
      |       ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...