# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1143387 | duyngadocton | Stove (JOI18_stove) | C++17 | 20 ms | 1480 KiB |
#include<bits/stdc++.h>
using namespace std;
#define task "stove"
#define pb push_back
#define ll long long
const int MAX = (int) 1e5;
int n, k;
int t[MAX + 5];
int main() {
if(fopen(task".inp","r")) {
freopen(task".inp","r",stdin);
freopen(task".out","w",stdout);
}
ios::sync_with_stdio(0);
cin.tie(NULL);cout.tie(NULL);
cin >> n >> k;
for(int i = 1; i <= n; ++i)
cin >> t[i];
vector<int> lst;
for(int i = 2; i <= n; ++i) {
lst.pb(t[i] - t[i - 1]);
}
sort(lst.begin(), lst.end());
reverse(lst.begin(), lst.end());
ll ds = 0;
for(int i = 1; i < k; ++i) ds += lst[i - 1];
cout << t[n] - ds - t[1] + k;
}
컴파일 시 표준 에러 (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... |