| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 708079 | yellowtoad | Stove (JOI18_stove) | C++17 | 63 ms | 4752 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
#include <algorithm>
#define int long long
using namespace std;
int n, k, a[100010], ans;
pair<int,int> d[100010];
vector<int> b;
signed main() {
cin >> n >> k;
for (int i = 1; i <= n; i++) cin >> a[i];
for (int i = 1; i < n; i++) d[i] = {a[i+1]-a[i],i};
sort(d+1,d+n,greater<pair<int,int>>());
b.push_back(0);
for (int i = 1; i < k; i++) b.push_back(d[i].second);
b.push_back(n);
for (int i = 1; i < b.size(); i++) ans += a[b[i]]+1-a[b[i-1]+1];
cout << ans << 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... | ||||
