Submission #1255955

#TimeUsernameProblemLanguageResultExecution timeMemory
1255955maxbrucelenStove (JOI18_stove)C++17
0 / 100
0 ms320 KiB
#include<bits/stdc++.h> using namespace std; using LL = long long; #define inf 1e18 #define maxn 200005 #define endl '\n' int n,K,p[maxn]; main(){ ios::sync_with_stdio(0); cin.tie(0); cin>>n>>K; for(int i=1;i<=n;++i){ cin>>p[i]; } int as = p[n]-p[1]+1; K--; vector<int> tmp; for(int i=2;i<=n;++i){ tmp.push_back(p[i]-p[i-1]-1); } sort(tmp.begin(),tmp.end(),greater<int>()); for(int i:tmp){ as -= i; if(!(--K)) break; } cout<<as<<endl; }

Compilation message (stderr)

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