| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 146080 | MathStudent2002 | Stove (JOI18_stove) | C++14 | 128 ms | 6052 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//wait darn
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef set<ll>::iterator slt;
ll st,fi;
multiset<ll> df;
ll K;
void input() {
int N; cin >> N >> K;
ll pre, cur;
for(int i = 0; i < N; i++) {
cin >> cur;
if(i == 0) st = cur;
else df.insert(pre-cur);
if(i == N-1) fi = cur+1;
else pre = cur+1;
}
}
void solve() {
K--;
ll ans = fi-st;
int i = 0;
slt it = df.begin();
for(; i < K; i++, it++) {ans += (*it);}
cout << ans << endl;
}
int main() {
input();
solve();
}
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
