| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1245431 | AMel0n | Stove (JOI18_stove) | C++20 | 12 ms | 1864 KiB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,N) for(ll i = 0; i < N; i++)
ll N, K, v[100001], gap[100001], res = 0;
signed main() {
cin.tie(0); ios::sync_with_stdio(false);
cin >> N >> K;
K--;
FOR(i,N) {cin >> v[i]; if (i) gap[i] = v[i] - v[i-1] - 1;}
nth_element(gap, gap + K, gap + N, greater<>());
FOR(i,K) res -= gap[i];
cout << res + v[N-1] + 1 - v[0];
}| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
