# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
155209 |
2019-09-27T06:40:31 Z |
kungfulon |
Stove (JOI18_stove) |
C++14 |
|
25 ms |
2236 KB |
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define repd(i,a,b) for(int i = (a);i >= (b);i--)
#define PB push_back
#define F first
#define S second
#define Task "stove"
using namespace std;
template <class T> T read(T &a){a = 0;char c = cin.get();bool nega = 0;while(!isdigit(c) && c != '-') c = cin.get();if(c == '-') nega = 1,c = cin.get();a = c - 48;c = cin.get();while(isdigit(c)) a = a * 10 + c - 48,c = cin.get();if(nega) a = -a;return a;}
template <class T> void writep(T a){if(a > 9) writep(a / 10);cout.put(a % 10 + 48);}
template <class T> void write(T a){if(a < 0) cout.put('-'),a = -a;writep(a);cout.put(' ');}
template <class T> void writeln(T a){write(a);cout.put('\n');}
const int N = 100012;
int n,k,a[N],b[N];
int main()
{
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// ifstream cin (Task".inp");
// ofstream cout (Task".out");
cin >> n >> k;
rep(i,1,n)
cin >> a[i];
rep(i,2,n) b[i] = a[i] - a[i-1] - 1;
sort(b+2,b+n+1,greater<int>());
int ans = a[n] - a[1] + 1;
rep(i,2,k) ans -= b[i];
cout << ans;
return 0;
}
# |
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 |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
380 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
468 KB |
Output is correct |
8 |
Correct |
2 ms |
348 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 |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
380 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
468 KB |
Output is correct |
8 |
Correct |
2 ms |
348 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 |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
380 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
468 KB |
Output is correct |
8 |
Correct |
2 ms |
348 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 |
24 ms |
2168 KB |
Output is correct |
17 |
Correct |
24 ms |
2040 KB |
Output is correct |
18 |
Correct |
25 ms |
2068 KB |
Output is correct |
19 |
Correct |
24 ms |
2236 KB |
Output is correct |
20 |
Correct |
24 ms |
2040 KB |
Output is correct |
21 |
Correct |
24 ms |
2040 KB |
Output is correct |
22 |
Correct |
24 ms |
2040 KB |
Output is correct |
23 |
Correct |
24 ms |
2040 KB |
Output is correct |
24 |
Correct |
24 ms |
2052 KB |
Output is correct |