# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1099959 | Trn115 | Stove (JOI18_stove) | C++11 | 15 ms | 3028 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define all(v) v.begin(), v.end()
using namespace std;
inline void setio(string name = "") {
cin.tie(0)->sync_with_stdio(0);
if (fopen((name+".INP").c_str(), "r")) {
freopen((name+".INP").c_str(), "r", stdin);
freopen((name+".OUT").c_str(), "w", stdout);
}
}
int n, k;
vector<int> t;
inline void input() {
cin >> n >> k;
t.resize(n);
for (int &i : t) cin >> i;
}
inline void solve() {
vector<int> g(n-1);
for (int i = 0; i < n-1; ++i) g[i] = t[i+1] - t[i] - 1;
int total = t.back() - t.front() + 1;
sort(all(g), greater<int>());
cout << total - accumulate(g.begin(), g.begin()+(k-1), 0);
}
signed main() {
setio();
input();
solve();
}
컴파일 시 표준 에러 (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... |