# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
990577 | 2024-05-30T16:26:24 Z | StuckOnA | Stove (JOI18_stove) | C++17 | 0 ms | 348 KB |
#include <bits/stdc++.h> using namespace std; #define pb push_back #define pf(x, y) (x).insert((x).begin(), y) #define int long long #define nosync() ios_base::sync_with_stdio(false); cin.tie(NULL); #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define db(x) cerr << #x << " = " << x << endl; #define duck cerr << "Duck" << endl; #define __ << ' ' << #define endl '\n' #define tcT template<class T #define mp make_pair #define f first #define s second #define cyn(x) cout << (x ? "YES" : "NO") << endl; //#define remove_debug using str = string; using pi = pair<int, int>; using vi = vector<int>; using vs = vector<str>; using vpi = vector<pi>; using si = set<int>; using mi = map<int, int>; using mc = map<char, int>; using ms = map<str, int>; tcT > void input (vector<T> &x) { for (auto &i : x) cin >> i; } tcT > void print (T x) { for (auto i : x) cout << i << ' '; cout << endl; } tcT > void printfs (T x) { for (auto i : x) cout << i.f __ i.s << endl; } tcT > void empty (T x) {} #ifdef remove_debug #define cerr if(false) cerr #define print(x) empty(x) #define printfs(x) empty(x) #endif void init() { fclose(fopen("output.txt", "w")); freopen("input.txt", "r", stdin); freopen("output.txt", "a", stdout); freopen("output.txt", "a", stderr); } void usaco(char *S) { char I[99],O[99]; sprintf(I,"%s.in",S); sprintf(O,"%s.out",S); freopen(I,"r",stdin); freopen(O,"w",stdout); } void solve() { int n, k; cin >> n >> k; vi v(n), vd(n - 1); input(v); for (int i = 0; i < n - 1; i++) vd[i] = v[i + 1] - v[i] - 1; sort(rall(vd)); int sum = 0; for (int i = 0; i < k - 1; i++) sum += vd[i]; cout << *max_element(all(v)) - sum << endl; } signed main() { nosync(); #ifdef local init(); #else //usaco("task_name"); #endif int t = 1; //cin >> t; for (int c = 1; c <= t; c++) { //cerr << "Case" << c << ": "; solve(); } return 0; }
Compilation message
# | 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 | - |