# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1255957 | maxbrucelen | Stove (JOI18_stove) | C++17 | 12 ms | 1480 KiB |
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
#define inf 1e18
#define maxn 200005
#define endl '\n'
int n,K,p[maxn];
main(){
ios::sync_with_stdio(0); cin.tie(0);
cin>>n>>K;
for(int i=1;i<=n;++i){
cin>>p[i];
}
int as = p[n]-p[1]+1;
K--;
vector<int> tmp;
for(int i=2;i<=n;++i){
tmp.push_back(p[i]-p[i-1]-1);
}
sort(tmp.begin(),tmp.end(),greater<int>());
for(int i:tmp){
if(K==0) break;
K--;
as -= i;
}
cout<<as<<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... |