# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1017488 |
2024-07-09T08:22:00 Z |
vjudge1 |
Stove (JOI18_stove) |
C++17 |
|
0 ms |
348 KB |
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree <int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define nemeshay ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define allr(pon) pon.rbegin(), pon.rend()
#define all(pon) pon.begin(), pon.end()
#define nosolve cout << "-1\n"
#define YES cout << "YES\n"
#define Yes cout << "Yes\n"
#define pii pair <int, int>
#define OK cout << "OK\n"
#define Ok cout << "Ok\n"
#define NO cout << "NO\n"
#define No cout << "No\n"
#define pf push_front
#define int long long
#define pb push_back
#define sigma signed
#define sc second
#define fr first
using namespace __gnu_pbds;
using namespace std;
const int N = 1e6 + 20, INF = 1e10 + 7;
int a[N], pref[N];
sigma main(){
nemeshay
int n, k, ans;
cin >> n >> k;
vector <int> pon;
for (int i = 0; i < n; i++) cin >> a[i];
ans = a[n - 1] + 2 - a[0];
if (k == 1) {
cout << ans - 1;
return 0;
}
if (k == n) {
cout << n;
return 0;
}
for (int i = 1; i < n; i++) pon.pb(a[i] - a[i - 1] - 1);
sort (pon.rbegin(), pon.rend());
for (int i = 0; i < k; i++) ans -= pon[i];
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |