1 条题解

  • 1
    @ 2021-8-7 18:41:45

    C++ :

    #include<cstdio>
    #include<cstring>
    #define  N  210000
    using  namespace  std;
    struct  node
    {
    	int  x,y,z;
    }a[N];int  n;
    inline  int  mymin(int  x,int  y){return  x<y?x:y;}
    int  check(long  long  x)
    {
    	int  ans=0;
    	for(int  i=1;i<=n;i++)
    	{
    		if(a[i].x<=x)ans+=(mymin(a[i].z,x)-a[i].x)/a[i].y+1;
    	}
    	return  ans;
    }
    int  main()
    {
    	int  T;
    	scanf("%d",&T);
    	while(T--)
    	{
    		scanf("%d",&n);
    		for(int  i=1;i<=n;i++)scanf("%d%d%d",&a[i].x,&a[i].z,&a[i].y);
    		long  long  l=0,r=2147483647,mid,ans=-1;
    		
    		while(l<=r)
    		{
    			mid=(l+r)>>1;
    			if(check(mid)&1)r=mid-1,ans=mid;
    			else  l=mid+1;
    		}
    		if(ans>=0)printf("%lld %d\n",ans,check(ans)-check(ans-1));
    		else  printf("There's no weakness.\n");
    	}
    	return  0;
    }
    
    • 1

    信息

    ID
    31
    时间
    1000ms
    内存
    128MiB
    难度
    1
    标签
    递交数
    78
    已通过
    66
    上传者