이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define ull unsigned long long int
#define pb push_back
#define pf push_front
#define en cout<<endl;
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define no1 {cout<<-1<<'\n'; r0}
#define no0 {cout<<0<<'\n'; r0}
#define yes_r { cout<<"YES\n"; return ; }
#define no_r { cout<<"NO\n"; return ; }
#define r0 return ;
#define fr first
#define sc second
#define srt(name) sort(name.begin(), name.end());
#define rev(name) reverse(name.begin(), name.end());
#define TT { ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0) ; int tt; cin>>tt; while (tt--) son_of_the_main(); }
#define TT1 { son_of_the_main(); }
#define TTi { while(1) son_of_the_main(); }
#define IMP { cout<<"Impossible\n"; r0 }
string all = "abcdefghijklmnopqrstuvwxyz";
string Call= "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string Vow = "aeiou";
const int INF=1e9+1;
const int mod=998244353;
const int N=1e6+10;
void son_of_the_main()
{
int n, k;
cin>>n>>k;
int v[n];
vector<int> segs;
for (int i=0; i<n; i++){
cin>>v[i];
if (i!=0) segs.pb(v[i]-v[i-1]-1);
}
srt(segs);
int cnt=n;
for (int i=0; i<n-k; i++){
cnt+=segs[i];
}
cout<<cnt;
}
int main()
{
ios_base::sync_with_stdio(0) ;
cin.tie(0) ;
TT1
}
/* comment box */
/**
**/
/*
freopen("output.txt", "w", stdout);
freopen("input.txt", "r", stdin);
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |