| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1286842 | Faisal_Saqib | Snowball (JOI21_ho_t2) | C++20 | 2595 ms | 2028 KiB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll inf=2e18,N=2e5+10;
ll a[N],qry[N];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
// ll tp=9e18;
// cout<<tp<<endl;
ll n,q;
cin>>n>>q;
a[0]=-inf;
a[n+1]=inf;
for(int i=1;i<=n;i++)
{
cin>>a[i];
}
for(int i=1;i<=q;i++)
{
cin>>qry[i];
if(i>1)qry[i]+=qry[i-1];
}
for(int i=1;i<=n;i++)
{
// a[i-1] .. a[i] .. a[i+1]
// find min x a[i-1]<=x and x<=a[i]
// time(x+1,i-1)>time(x,i)
ll l=a[i-1]-1,r=a[i];
while(l+1<r)
{
ll mid=(l+r)/2;
bool pos=0;
for(int j=0;j<=q;j++)
{
if(a[i]+qry[j]<=mid)
{
pos=1;
break;
}
if(a[i-1]+qry[j]>=(mid+1))
{
pos=0;
break;
}
}
if(pos)
{
r=mid;
}
else
{
l=mid;
}
}
ll st=r;
l=a[i],r=a[i+1]+1;
while(l+1<r)
{
ll mid=(l+r)/2;
bool pos=0;
for(int j=0;j<=q;j++)
{
if(a[i]+qry[j]>=mid)
{
pos=1;
break;
}
if(a[i+1]+qry[j]<=(mid-1))
{
pos=0;
break;
}
}
if(pos)
{
l=mid;
}
else
{
r=mid;
}
}
// cout<<"Hola "<<i<<' '<<st<<' '<<l<<endl;
cout<<l-st<<endl;
}
}
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
