# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1083270 | Dennis_Jason | Stove (JOI18_stove) | C++17 | 17 ms | 2620 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define NMAX 2005
#define pb push_back
#define eb emplace_back
#define MOD 100003
#define nl '\n'
#define LLONG_MAX 9223372036854775807
#define pii pair<int,int>
#define tpl tuple<int,int,int>
//#pragma GCC optimize("O3")
#define INF 2147483647
using namespace std;
ifstream fin("aib.in");
ofstream fout("aib.out");
/*
*
*
================DEMONSTRATION===================
5 5
RGRGW
GRRGW
WGGWR
RWRGW
RGWGW
=====================END========================
*/
int n,k;
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin>>n>>k;
vector<pii>v(n+1);
for(int i=1;i<=n;++i)
{
cin>>v[i].first;
v[i].second=v[i].first+1;
}
vector<int>timp(n);
for(int i=2;i<=n;++i)
{
int aux=(v[i].first-v[i-1].second);
timp[i-1]=aux;
// cout<<timp[i-1]<<" ";
}
sort(timp.begin()+1,timp.end(),greater<int>());
int ans=0;
k--;
for(int i=1;i<n && k--;++i)
{
ans+=timp[i];
}
cout<<(v[n].second-v[1].first)-ans;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |