Submission #1106080

#TimeUsernameProblemLanguageResultExecution timeMemory
1106080ngokhanhStove (JOI18_stove)C++17
100 / 100
21 ms3160 KiB
#include<bits/stdc++.h> using namespace std; #define rep(i,a,b) for (int i=a;i<=b;i++) #define rep2(i,a,b,c) for (int i=a;i<=b;i+=c) #define rev(i,a,b) for (int i=a;i>=b;i--) #define rev2(i,a,b,c) for (int i=a;i>=b;i-=c) #define ii pair<ll,ll> #define bit(i,j) ((i>>j)&1) #define ull unsigned long long #define pb push_back #define pf push_front #define ll long long #define F first #define S second #define sz(a) (int)(a.size()) #define on(n) __builtin_popcountll(n) #define ld long double #define __log2(x) 63-__builtin_clzll(x) #define Mask(x) (1LL<<x) #define ALL(v) v.begin(),v.end() const int N=3e5+5; const int mod=998244353; int n,k,T[N]; void solution(){ cin >> n >> k; rep(i,1,n) cin >> T[i]; ll res=T[n]-T[1]+1; k--; priority_queue<ll> pq; rep(i,2,n) pq.push(T[i]-T[i-1]-1); while(k--){ res-=pq.top(); pq.pop(); } cout << res; } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int test=1; //cin >> test; while(test--) solution(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...