# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
864439 | VN_AnhTuan | Stove (JOI18_stove) | C++14 | 471 ms | 5028 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 fi first
#define se second
#define pii pair<int, int>
#define mp make_pair
#define pb push_back
#define bit(X,i) ((X>>i)&1)
#define fori(i,d,c) for(int i = d; i <= c; ++ i)
#define ford(i,d,c) for(int i = d; i >= c; -- i)
#define all(V) V.begin(), V.end()
#define RRH(V) V.resize(unique(all(V))-V.begin())
#define debug(x) { cerr << #x << " = "; cerr << (x) << '\n'; }
#define open(Task) if (fopen(Task".inp", "r")) {freopen(Task".inp", "r", stdin);freopen(Task".out", "w", stdout);}
using namespace std;
using ll = long long;
using ld = long double;
const int maxn = 1e5 + 5;
const int maxm = 1e5 + 5;
const int base = 101;
int n, m, a[maxn];
void read() {
cin >> n >> m; m --;
fori(i,1,n) cin >> a[i];
}
void solve() {
priority_queue<int> pq;
fori(i,2,n) {
pq.push(max(0,a[i] - (a[i-1] + 1)));
debug(a[i] - (a[i-1] + 1));
}
int res = a[n] - a[1] + 1;
while(m --> 0 && !pq.empty()) {
res -= pq.top();
pq.pop();
}
cout << res;
}
int main () {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
open("stove");
read();
solve();
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... |