# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
202175 | tri | Stove (JOI18_stove) | C++14 | 78 ms | 2420 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
#define pb push_back
#define f first
#define s second
int main() {
int N, K;
cin >> N >> K;
vi times(N);
for (int i = 0; i < N; i++) {
cin >> times[i];
}
sort(times.begin(), times.end());
int sum = times[times.size() - 1] - times[0] + 1;
vi spaces;
for (int i = 0; i + 1 < N; i++) {
int space = times[i + 1] - times[i] - 1;
if (space > 0) {
spaces.pb(space);
}
}
sort(spaces.begin(), spaces.end());
reverse(spaces.begin(), spaces.end());
for (int i = 0; i < spaces.size() && i < K - 1; i++) {
sum -= spaces[i];
}
cout << sum << endl;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |