QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#507393 | #5253. Denormalization | thangthang# | WA | 2ms | 3720kb | C++20 | 1.8kb | 2024-08-06 17:16:25 | 2024-08-06 17:16:26 |
Judging History
answer
#include<bits/stdc++.h>
#define lc(x) (x<<1)
#define rc(x) (x<<1|1)
#define mid (l+r>>1)
using namespace std;
const int maxn=200005,maxt=maxn<<2;
int n,m,T,ans;
long long a[maxn];
struct vec{
long long x,y;
}p[maxn],st;
vec operator +(vec a,vec b){
return vec{a.x+b.x,a.y+b.y};
}
vec operator -(vec a,vec b){
return vec{a.x-b.x,a.y-b.y};
}
__int128 operator ^(vec a,vec b){
return (__int128)a.x*b.y-(__int128)a.y*b.x;
}
int cmp(vec a,vec b){
return a.x<b.x||(a.x==b.x&&a.y<b.y);
}
struct hull{
vector<vec>p,stk;
void clear(){
p.clear(),stk.clear();
}
void ins(vec x){
p.emplace_back(x);
}
void build(){
//sort(p.begin(),p.end(),cmp);
for(int i=0;i<p.size();i++){
if(i>0&&p[i].x==p[i-1].x&&p[i].y==p[i-1].y)
continue;
while(stk.size()>1&&((stk.back()-stk[stk.size()-2])^(p[i]-stk.back()))<=0)
stk.pop_back();
stk.emplace_back(p[i]);
}
}
}h[maxt];
void build(int l,int r,int now){
h[now].clear();
for(int i=l;i<=r;i++)
h[now].ins(vec{i,a[i]});
h[now].build();
if(l==r)
return ;
build(l,mid,lc(now)),build(mid+1,r,rc(now));
}
void query(int l,int r,int now,int L,int R){
if(L<=l&&r<=R){
int L=-1,R=h[now].stk.size()-1;
while(L+1<R){
int MID=(L+R>>1);
if(((h[now].stk[MID]-st)^(h[now].stk[MID+1]-h[now].stk[MID]))<=0)
L=MID;
else R=MID;
}
if(h[now].stk[L+1].y<st.y)
ans=-1;
ans=min(ans,(int)((h[now].stk[L+1].y-st.y)/(h[now].stk[L+1].x-st.x)));
return ;
}
if(L<=mid)
query(l,mid,lc(now),L,R);
if(mid<R)
query(mid+1,r,rc(now),L,R);
}
int main(){
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++)
scanf("%lld",&a[i]),a[i]+=a[i-1];
build(1,n,1);
for(int i=1,x,y;i<=m;i++){
scanf("%d%d",&x,&y),y=x+y-1,st=vec{x-1,a[x-1]};
ans=1e9,query(1,n,1,x,y);
if(ans<0)
puts("stay with parents");
else printf("%d\n",ans);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 3720kb
input:
2 0.909840249060 0.414958698174
output:
result:
wrong output format Unexpected end of file - int32 expected