Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
26648 | fyq & jbh's LCA | 【BJ】T1 | C++ | 解答错误 | 2 | 1000 MS | 14336 KB | 1499 | 2024-02-21 13:21:46 |
#include<bits/stdc++.h> #define up(i,l,r) for(int i=(l);i<=(r);++i) #define down(i,l,r) for(int i=(l);i>=(r);--i) #define m_p make_pair #define p_b push_back #define pi pair<int,int> #define p1 first #define p2 second #define x1 x114514 #define y1 y114514 #define double long double using namespace std; typedef long long ll; const int maxn=3e5+10; const double eps=1e-5; inline ll read(){ ll x=0;short t=1; char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')t=-1;ch=getchar();} while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar(); return x*t; }int n,q; double A[maxn],H[maxn],S[maxn],pos[maxn]; bool chk(double w,double x,double y){ double lm=w/2; if(x<0)x=-x; if(y>lm)y=w-y; return (x<=y); } void slv(){ cin>>n>>q;up(i,1,n)cin>>S[i]>>A[i]; double s=0; up(i,1,n){ s+=S[i]; pos[i]=sqrt(s); } while(q--){ double h,x; cin>>h>>x; if(!chk(pos[n]*sqrt(2),h,fabs(h))){ printf("0\n");continue; }double hh=pos[n]*sqrt(2)-abs(h); if(hh-x<fabs(h)){ printf("0\n");continue; } int l=-1,r=n; while(l+1<r){ int mid=l+r>>1; if(chk(pos[mid]*sqrt(2),h,hh-x))r=mid; else l=mid; }printf("%d\n",r); } }int main(){ // freopen("snow.in","r",stdin); // freopen("snow.out","w",stdout); slv(); fclose(stdin); fclose(stdout); return 0; }