# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
818752 |
2023-08-10T06:37:52 Z |
vjudge1 |
Stove (JOI18_stove) |
C++17 |
|
17 ms |
2276 KB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define el cout<<endl;
#define ff for(int i=0;i<n;i++)
#define fr(n,m) for(int i=n;i<m;i++)
#define frj(n,m) for(int j=n;j<m;j++)
#define frl(n,m) for(int l=n;l<m;l++)
#define frd(n,m) for(int d=n;d<m;d++)
#define mii map<int,int>
#define mci map<char,int>
#define vi vector<int>
#define vc vector<char>
#define pb push_back
#define als(z) cout<<z.fi<<" "<<z.se<<endl;
#define all(n) n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
const int mod = 1e9 + 7;
// const int mod=998
int i = 0, j = 0, k = 0, l = 0, h = 0, w = 0, a = 0, b = 0, c = 0, d = 0, n = 0, m = 0;
int num = 0, ans = 0, sum = 0;
const int N = 1e3 + 5;
void solve() {
cin >> n >> k;
vi v(n);
ff{
cin >> v[i];
}
vi w;
fr(1, n) {
w.pb(v[i] - v[i - 1] - 1);
// cout << v[i] - v[i - 1] - 1 << " ";
}
sort(rall(w));
l = v[n - 1] + 1 - v[0];
// cout << v[n - 1] + 1 - v[0];
fr(0, k - 1) {
l -= w[i];
}
cout << l;
// el;
// for (auto z : w) cout << z << " ";
}
signed main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int T = 1;
// cin >> T;
while (T--) {
cout << fixed << setprecision(12); solve();
el;
} return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
14 ms |
2260 KB |
Output is correct |
17 |
Correct |
15 ms |
2260 KB |
Output is correct |
18 |
Correct |
14 ms |
2276 KB |
Output is correct |
19 |
Correct |
15 ms |
2164 KB |
Output is correct |
20 |
Correct |
14 ms |
2260 KB |
Output is correct |
21 |
Correct |
14 ms |
2260 KB |
Output is correct |
22 |
Correct |
14 ms |
2272 KB |
Output is correct |
23 |
Correct |
15 ms |
2260 KB |
Output is correct |
24 |
Correct |
17 ms |
2268 KB |
Output is correct |