# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
146927 | 2019-08-26T16:44:28 Z | GodTe | Stove (JOI18_stove) | C++14 | 29 ms | 1524 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> Pi; typedef pair<ll, ll> Pll; // #define TT() printf("%.4f sec\n", (double) clock() / CLOCKS_PER_SEC ) #define Fi first #define Se second #define rep(i, n) for(ll i=0;i<n;i++) #define repp(i, n) for(ll i=1;i<=n;i++) #define INF 1987654321 #define IINF 987654321987654321 int n,k; vector<int> v,v1; int main(){ scanf("%d%d",&n,&k); repp(i,n){ int x; scanf("%d",&x); v.push_back(x); } int ans = v[n-1]-v[0]+1; rep(i,n-1) v1.push_back(v[i+1]-v[i]-1); sort(v1.begin(),v1.end(),greater<int>()); rep(i,min(n-1,k-1)) ans -= v1[i]; printf("%d\n",ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 256 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 256 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 3 ms | 376 KB | Output is correct |
11 | Correct | 3 ms | 376 KB | Output is correct |
12 | Correct | 3 ms | 376 KB | Output is correct |
13 | Correct | 3 ms | 376 KB | Output is correct |
14 | Correct | 3 ms | 376 KB | Output is correct |
15 | Correct | 3 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 256 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 3 ms | 376 KB | Output is correct |
11 | Correct | 3 ms | 376 KB | Output is correct |
12 | Correct | 3 ms | 376 KB | Output is correct |
13 | Correct | 3 ms | 376 KB | Output is correct |
14 | Correct | 3 ms | 376 KB | Output is correct |
15 | Correct | 3 ms | 376 KB | Output is correct |
16 | Correct | 27 ms | 1520 KB | Output is correct |
17 | Correct | 28 ms | 1520 KB | Output is correct |
18 | Correct | 27 ms | 1412 KB | Output is correct |
19 | Correct | 29 ms | 1520 KB | Output is correct |
20 | Correct | 29 ms | 1492 KB | Output is correct |
21 | Correct | 28 ms | 1520 KB | Output is correct |
22 | Correct | 28 ms | 1520 KB | Output is correct |
23 | Correct | 27 ms | 1492 KB | Output is correct |
24 | Correct | 28 ms | 1524 KB | Output is correct |