# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
931887 | 2024-02-22T14:09:43 Z | lovrot | Stove (JOI18_stove) | C++17 | 1 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--; ) ans -= A[k]; printf("%d\n", ans); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Incorrect | 0 ms | 348 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Incorrect | 0 ms | 348 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Incorrect | 0 ms | 348 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |