제출 #1122658

#제출 시각아이디문제언어결과실행 시간메모리
1122658imarnStove (JOI18_stove)C++20
0 / 100
1 ms324 KiB
#include<bits/stdc++.h> #define ll long long #define pii pair<int,int> #define pll pair<ll,ll> #define plx pair<ll,int> #define f first #define s second #define pb push_back #define all(x) x.begin(),x.end() #define szz(r) (ll)r.size() #define vi vector<int> #define vvi vector<vi> #define pp pair<ll,int> #define ub(x,i) upper_bound(all(x),i)-x.begin() using namespace std; const int mxn=1e5+5; int main(){ ios_base::sync_with_stdio(0);cin.tie(0); int n,k;cin>>n>>k; ll a[n];cin>>a[0]; priority_queue<ll>pq; for(int i=1;i<n;i++)cin>>a[i],pq.push(a[i]-a[i-1]-1); k--;ll rs=0; while(!pq.empty()&&k>0){ rs+=pq.top();pq.pop();k--; }cout<<a[n-1]-rs; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...