| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1283665 | hoangnoobpro | Stove (JOI18_stove) | C++20 | 1 ms | 572 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],l,r,mid,kq;
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];
}
sort(a+1,a+n+1);
l=1;
r=1e9;
while(l<r)
{
mid=(l+r)/2;
d=1;
x=1;
for(i=2;i<=n;++i)
{
if(a[i]-a[x]>mid)
{
x=i;
d++;
}
}
if(d<=k)
{
kq=mid;
r=mid-1;
}
else l=mid+1;
}
x=1;
d=0;
for(i=1;i<=n;++i)
{
if(a[i]-a[x]>kq)
{
d+=(a[i-1]-a[x]+1);
x=i;
}
}
d+=(a[n]-a[x]+1);
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... | ||||
