# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
166760 |
2019-12-03T19:59:03 Z |
anubhavdhar |
Stove (JOI18_stove) |
C++14 |
|
94 ms |
2436 KB |
#include<bits/stdc++.h>
#define ll long long int
#define FOR(i,N) for(i=0;i<N;i++)
#define FORe(i,N) for(i=1;i<=N;i++)
#define FORr(i,a,b) for(i=a;i<b;i++)
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define vi vector<ll>
#define ii pair<ll,ll>
#define vii vector<ii>
const ll MAXN = 1e5;
const ll LOGN = 17;
const ll ROOTN = 320;
const ll INF = 1e17+21;
const ll MOD = 1e9 + 7;
using namespace std;
int main()
{
ll N,i,K,ans = 1,prev = 0,curr = 0;
vi diff;
cin>>N>>K;
K = N-K;
cin>>prev;
ans = N;
FOR(i,N - 1)
{
cin>>curr;
diff.pb(curr - prev - 1);
prev = curr;
}
sort(diff.begin(),diff.end());
FOR(i,K)
ans += diff[i];
cout<<ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
256 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 |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
380 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
8 |
Correct |
2 ms |
376 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 |
256 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 |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
380 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
4 ms |
380 KB |
Output is correct |
11 |
Correct |
4 ms |
376 KB |
Output is correct |
12 |
Correct |
4 ms |
376 KB |
Output is correct |
13 |
Correct |
4 ms |
376 KB |
Output is correct |
14 |
Correct |
4 ms |
376 KB |
Output is correct |
15 |
Correct |
4 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 |
256 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 |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
380 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
4 ms |
380 KB |
Output is correct |
11 |
Correct |
4 ms |
376 KB |
Output is correct |
12 |
Correct |
4 ms |
376 KB |
Output is correct |
13 |
Correct |
4 ms |
376 KB |
Output is correct |
14 |
Correct |
4 ms |
376 KB |
Output is correct |
15 |
Correct |
4 ms |
376 KB |
Output is correct |
16 |
Correct |
84 ms |
2416 KB |
Output is correct |
17 |
Correct |
84 ms |
2388 KB |
Output is correct |
18 |
Correct |
94 ms |
2284 KB |
Output is correct |
19 |
Correct |
85 ms |
2420 KB |
Output is correct |
20 |
Correct |
85 ms |
2408 KB |
Output is correct |
21 |
Correct |
84 ms |
2416 KB |
Output is correct |
22 |
Correct |
85 ms |
2304 KB |
Output is correct |
23 |
Correct |
85 ms |
2436 KB |
Output is correct |
24 |
Correct |
89 ms |
2384 KB |
Output is correct |