# 防线 2020/3/31

## 样例

3
2
1 10 1
2 10 1
2
1 10 1
1 10 1
4
1 10 1
4 4 1
1 5 1
6 10 1

### 样例输出

1 1
There’s no weakness.
4 3

Si≤Ei,

1≤T≤5,

N≤200000,

0≤Si，Ei，Di≤231−1

## 我的见解

#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
const int N = 200000 + 1, INF = 1e9;
int t,n;
struct CJG{
int s,e,d;
}a[N];

int getSum(int x);
bool check(int l,int r);

int main(){
scanf("%d", &t);
while(t--){
scanf("%d", &n);
int maxn = -INF, minn = INF;
for(int i = 1; i <= n; i++){
scanf("%d %d %d", &a[i].s, &a[i].e, &a[i].d);
minn = min(minn,a[i].s);
maxn = max(maxn,a[i].e);
}

if(!(getSum(maxn) & 1)){
printf("There's no weakness.\n");
}else{
int l = minn, r = maxn;
while(l <= r){
int mid = (l + r) >> 1;
if(check(l,mid))r = mid - 1;
else l = mid + 1;
}

printf("%d %d\n", l, (getSum(l) - getSum(l - 1)));
}
}
return 0;
}

bool check(int l,int r){
return (getSum(r) - getSum(l - 1)) & 1;
}

int getSum(int x){
int res = 0;
for(int i = 1; i <= n; i++)
if(a[i].s <= x)
res += (min(a[i].e, x) - a[i].s)/a[i].d + 1;

return res;
}

• 点赞
• 评论
• 分享
x

海报分享

扫一扫，分享海报

• 收藏
• 打赏

打赏

cqbz_ChenJiage

你的鼓励将是我创作的最大动力

C币 余额
2C币 4C币 6C币 10C币 20C币 50C币
• 举报
• 一键三连

点赞Mark关注该博主, 随时了解TA的最新博文

08-19 47

04-14 120
09-12 38
10-24 135
09-19 66
08-04 173
03-27 428
05-19
12-20
09-18