이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/**
* بسم الله الرحمن الرحيم *
﴾ رَبِّ اشْرَحْ لِي صَدْرِي * وَيَسِّرْ لِي أَمْرِي * وَاحْلُلْ عُقْدَةً مِّن لِّسَانِي * يَفْقَهُوا قَوْلِي ﴿
*/
/// author : "ASGA"
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define ONLINE 0
#ifdef ONLINE_JUDGE
#undef ONLINE;
#define ONLINE 1
#endif
#define dbg(a) if(!ONLINE)cout << a << ' ';
const ll inf = 1e18;
signed main(){
ios_base::sync_with_stdio(0);cin.tie();
int n,k;cin >> n >> k;
vector <int> a(n);
for(int& i : a)cin >> i;
ll ans = a.back() + 1 - a[0];
multiset <int> s;
for(int i = 0;i + 1 < n;i++)s.insert(a[i + 1] - a[i]);
auto i = s.rbegin();
while(--k){ans -= (*i++);ans++;}
cout << ans << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |