# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
146927 | GodTe | Stove (JOI18_stove) | C++14 | 29 ms | 1524 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
// #define TT() printf("%.4f sec\n", (double) clock() / CLOCKS_PER_SEC )
#define Fi first
#define Se second
#define rep(i, n) for(ll i=0;i<n;i++)
#define repp(i, n) for(ll i=1;i<=n;i++)
#define INF 1987654321
#define IINF 987654321987654321
int n,k; vector<int> v,v1;
int main(){
scanf("%d%d",&n,&k);
repp(i,n){
int x; scanf("%d",&x); v.push_back(x);
}
int ans = v[n-1]-v[0]+1;
rep(i,n-1) v1.push_back(v[i+1]-v[i]-1);
sort(v1.begin(),v1.end(),greater<int>());
rep(i,min(n-1,k-1)) ans -= v1[i];
printf("%d\n",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... |