이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
///
/// You fell for it, fool!
/// Thunder Cross Split Attack!
///
#include <bits/stdc++.h>
#define Loop(x,l,r) for(ll x = ll(l); x < ll(r); ++x)
typedef long long ll;
using namespace std;
const int N = 100'010;
int t[N], u[N];
int n, k;
int main()
{
ios::sync_with_stdio(false); cin.tie(0);
cin >> n >> k; --k;
Loop(i,0,n) cin >> t[i];
Loop(i,0,n-1) u[i] = t[i+1]-t[i]-1;
sort(u,u+n-1,greater<int>());
int ans = t[n-1]-t[0]+1;
Loop(i,0,k) ans -= u[i];
cout << ans << '\n';
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |