| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1283666 | hoangnoobpro | Stove (JOI18_stove) | C++20 | 15 ms | 2020 KiB |
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define nmax 1000007
#define fi first
#define se second
#define ll long long
ll t=1,n,m,i,j,d=0,x=0,k=0,y,z,a[nmax],f[nmax],b[nmax],cnt=0;
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>n>>k;
for(i=1;i<=n;++i)
{
cin>>a[i];
}
for(i=1;i<n;++i)
{
b[i]=a[i+1]-a[i]-1;
}
x=k-1;
sort(b+1,b+n);
d=a[n]-a[1]+1;
for(i=n-1;i>=1;--i)
{
if(x==0)break;
d-=b[i];
x--;
}
cout<<d;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
