# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
857097 |
2023-10-05T11:30:07 Z |
alicanyaz |
Stove (JOI18_stove) |
C++14 |
|
40 ms |
2508 KB |
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
#define xc3(x) (x*(x-1)*(x-2)/6)
#define xc2(x) ((x)*((x)-1)/2)
#define abs(x) ((x)>0?(x):-((x)))
#define min(x,y) ((x)>(y)?(y):(x))
//#define debug 1
using namespace std;
using namespace __gnu_pbds;
//void FILEREAD(){freopen("text_input.txt","r",stdin);freopen("output.txt","w",stdout);}
#define ll long long
#define ull unsigned long long
#define pi pair<int,int>
#define pll pair<long long,long long>
#define pli pair<long long,int>
#define pil pair<int,long long>
#define vi vector<int>
#define vll vector<long long>
#define vpi vector<pair<int,int>>
#define vpll vector<pair<long long,long long>>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
#define vvpi vector<vector<pair<int,int>>>
#define vvpll vector<vector<pair<long,long>>>
#define vec vector
#define pr pair
#define fi first
#define se second
#define fr(i,j) for(int i=0;i<j;i++)
#define testcase(x) int x;cin>>x;while(x--)solve()
#define vecinp(v) for(auto &in_vx:v)cin>>in_vx
#define pb push_back
typedef tree<ll,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_Set;
ordered_Set os;
#define MAX 99999997
#define MOD 92182
#define maxM 1000005
int main(){
int N,K;cin>>N>>K;
vll v(N);for(auto &x:v)cin>>x;
ll r = N;
vll s;
for(int i=1;i<N;i++){
s.pb(v[i]-v[i-1]-1);
r+=v[i]-v[i-1]-1;
}
sort(s.begin(),s.end(),greater<ll>());
fr(i,K-1)r-=s[i];
cout << r << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
600 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
432 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
600 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
432 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
2 ms |
348 KB |
Output is correct |
13 |
Correct |
2 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
456 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
600 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
432 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
2 ms |
348 KB |
Output is correct |
13 |
Correct |
2 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
456 KB |
Output is correct |
16 |
Correct |
38 ms |
2352 KB |
Output is correct |
17 |
Correct |
33 ms |
2248 KB |
Output is correct |
18 |
Correct |
33 ms |
2360 KB |
Output is correct |
19 |
Correct |
40 ms |
2252 KB |
Output is correct |
20 |
Correct |
35 ms |
2260 KB |
Output is correct |
21 |
Correct |
33 ms |
2256 KB |
Output is correct |
22 |
Correct |
33 ms |
2252 KB |
Output is correct |
23 |
Correct |
38 ms |
2508 KB |
Output is correct |
24 |
Correct |
33 ms |
2248 KB |
Output is correct |