# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
72983 | garyye | Stove (JOI18_stove) | C++14 | 39 ms | 1532 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.
// author: gary
// created: 2018/08/27 12:55:13
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <limits>
#include <utility>
#include <functional>
#include <string>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <algorithm>
#include <iostream>
#include <sstream>
using namespace std;
#define SZ(x) ( (int) (x).size() )
#define ALL(c) (c).begin(), (c).end()
#define CNT(c, x) ((c).find(x) != (c).end())
typedef pair<int, int> pii;
typedef long long ll;
template<class T> bool cmax(T& a, T b) { if(a < b) { a = b; return true; } return false; }
template<class T> bool cmin(T& a, T b) { if(a > b) { a = b; return true; } return false; }
const int N = 1e5 + 10;
int t[N];
int a[N];
int n, k;
int main() {
while(scanf("%d%d", &n, &k) != EOF) {
for(int i = 0; i < n; i++) {
scanf("%d", t + i);
if(i > 0) {
a[i - 1] = t[i] - t[i - 1] - 1;
}
}
sort(a, a + n - 1);
reverse(a, a + n - 1);
int ans = t[n - 1] + 1 - t[0];
for(int i = 0; i < k - 1; i++) {
ans -= a[i];
}
printf("%d\n", 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... |