Submission #246730

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
2467302020-07-10 03:36:36quadraticreciprocityStove (JOI18_stove)C++14
100 / 100
78 ms3312 KiB
#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];
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...