# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
931891 | 2024-02-22T14:13:53 Z | lovrot | Stove (JOI18_stove) | C++17 | 0 ms | 348 KB |
#include <cstdio> #include <algorithm> #include <cstring> #include <cmath> #include <iostream> #include <set> #include <queue> #include <deque> #include <vector> #include <random> #include <chrono> #define X first #define Y second #define PB push_back #define EB emplace_back using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MOD = 1e9 + 7; // 998 244 353; const int N = 1e5 + 10; int n, k, A[N]; int main() { scanf("%d%d", &n, &k); int lst = 0, ans = 0; for(int i = 0; i < n; ++i) { int x; scanf("%d", &x); A[i] = x - lst - 1; if(!i) ans -= x; if(i == n - 1) ans += x + 1; lst = x; } sort(A + 1, A + n, [](int a, int b) { return a > b; }); for(; k; k--) ans -= A[k]; printf("%d\n", ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |