| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 636933 | birthdaycake | Stove (JOI18_stove) | C++17 | 96 ms | 8364 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define boost ios_base::sync_with_stdio(false), cin.tie(NULL);
using namespace std;
int a[200001];
signed main(){
int n,k, ans = 0; cin >> n >> k;
for(int i = 0; i < n; i++) cin >> a[i];
sort(a,a+n);
vector<pair<int,int>>d;
set<int>x;
for(int i = 0; i < n - 1; i++){
d.push_back({a[i + 1] - a[i], i});
}
sort(d.begin(), d.end());
reverse(d.begin(), d.end());
for(int i = 0; i < k - 1; i++){
x.insert(d[i].second);
}
int beg = INT_MAX, ed = 0;
for(int i = 0; i < n; i++){
beg = min(beg,a[i]);
ed = max(ed,a[i]);
if(x.count(i)){
ans += (ed - beg + 1);
beg = INT_MAX; ed = 0;
}
}
ans += (ed - beg + 1);
cout << ans;
return 0;
}컴파일 시 표준 에러 (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... | ||||
