Submission #237033

#TimeUsernameProblemLanguageResultExecution timeMemory
237033uacoder123Stove (JOI18_stove)C++14
100 / 100
28 ms2200 KiB
#include <bits/stdc++.h> using namespace std; #define F first #define S second #define FOR(i,a,b) for (auto i = (a); i <= (b); ++i) #define NFOR(i,a,b) for(auto i = (a); i >= (b); --i) #define all(x) (x).begin(), (x).end() #define sz(x) int(x.size()) #define mp(i,a) make_pair(i,a) #define pb(a) push_back(a) #define bit(x,b) (x&(1LL<<b)) typedef long long int lli; typedef pair <lli,lli> ii; typedef pair <ii,lli> iii; typedef vector <lli> vi; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); lli test; test=1; for(;test>0;--test) { lli n,k; cin>>n>>k; int t[n]; for(int i=0;i<n;++i) cin>>t[i]; sort(t,t+n); int d[n-1]; for(int i=0;i<n-1;++i) d[i]=t[i+1]-t[i]-1; sort(d,d+n-1); lli ans=n,x=0; while(k!=n) { ans+=d[x]; x++; k++; } cout<<ans<<endl; } return(0); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...