# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
246730 | quadraticreciprocity | Stove (JOI18_stove) | C++14 | 78 ms | 3312 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <array>
using std::cin; using std::cout;
using std::max; using std::min;
using std::vector; using std::string;
using ll=long long;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);
template<class T, class U> bool ckmin(T &a, U b){return (a>b? a=b, true : false);}
template<class T, class U> bool ckmax(T &a, U b){return (a<b? a=b, true: false);}
int main(){
ll n, k;
cin>>n>>k;
vector<ll> a(n);
for(int i=0;i<n;i++){
cin>>a[i];
}
vector<ll> dif;
for(int i=1;i<n;i++){
dif.push_back(a[i]-a[i-1]-1);
}
sort(dif.rbegin(), dif.rend());
/* sort(a.begin(), a.end()); */
ll ans = a[n-1]-a[0]+1;
for(int i=0;i<k-1;i++){
ans-=dif[i];
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |