# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1249347 | ammaka | Stove (JOI18_stove) | C++20 | 12 ms | 1864 KiB |
//#include <GOD>
//kole shahr khakestary , bala sar man ranginkamon
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
#define pb push_back
#define len length
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define freo freopen("guard.out","w",stdout)
#define frei freopen("guard.in","r",stdin)
const ll inf=1e18+10;
const ll mod=1e9+7;
const ll maxn=(1e5)+10,maxm=1e5+10,sq=310+10,maxa=(1<<maxn),mlg=32;
ll t[maxn],a[maxn];
int main(){
// frei;
// freo;
FAST_IO;
// ll t;
// cin>>t;
// while(t--){
// }
ll n,k;
cin>>n>>k;
for(int i=1;i<=n;i++){
cin>>t[i];
}
for(int i=1;i<=n-1;i++){
a[i]=t[i+1]-t[i]-1;
}
sort(a+1,a+n);
reverse(a+1,a+n);
ll ans=0;
for(int i=1;i<=k-1;i++){
ans+=a[i];
}
cout<<t[n]-t[1]+1-ans<<endl;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |