# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
926117 |
2024-02-12T15:07:17 Z |
daulet |
Stove (JOI18_stove) |
C++14 |
|
18 ms |
2908 KB |
#include<bits/stdc++.h>
// #include"virus.cpp"
#define IOS ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie()
#define ll long long
#define ull unsigned long long
#define pb push_back
// #define endl "\n"
#define int ll
#define F first
#define S second
#define pii pair<int,int>
#define db double
#define ld long double
#define short unsigned short
using namespace std;
const int inf = 1e9,MOD=1e9+7,N=2005,MN=1e9+7;
void solve() {
int n,k;
cin>>n>>k;
vector<int>v(n);
for(int i=0;i<n;i++){
cin>>v[i];
}
vector<int>g(n-1);
for(int i=1;i<n;i++){
g[i-1]=v[i]-v[i-1]-1;
}
sort(g.begin(),g.end());
int loh=n-k;
int ans=n;
int i=0;
while(loh--){
ans+=g[i];
i++;
}
cout<<ans<<endl;
}
signed main() {
IOS;
//freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
int UwU=1;
// cin>>UwU;
while (UwU--) {
solve();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 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 |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 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 |
1 ms |
348 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 |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
476 KB |
Output is correct |
14 |
Correct |
1 ms |
512 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 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 |
1 ms |
348 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 |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
476 KB |
Output is correct |
14 |
Correct |
1 ms |
512 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
15 ms |
2772 KB |
Output is correct |
17 |
Correct |
15 ms |
2908 KB |
Output is correct |
18 |
Correct |
14 ms |
2908 KB |
Output is correct |
19 |
Correct |
15 ms |
2904 KB |
Output is correct |
20 |
Correct |
15 ms |
2908 KB |
Output is correct |
21 |
Correct |
15 ms |
2908 KB |
Output is correct |
22 |
Correct |
18 ms |
2908 KB |
Output is correct |
23 |
Correct |
14 ms |
2904 KB |
Output is correct |
24 |
Correct |
14 ms |
2904 KB |
Output is correct |