# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1122659 | imarn | Stove (JOI18_stove) | C++20 | 0 ms | 324 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);
ll n,k;cin>>n>>k;
ll a[n+1];a[0]=1;
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]-rs;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |