UOJ Logo

NOI.AC

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#201547#3494. binaryJosephcheng100668ms9008kbC++11394b2024-02-01 09:24:362024-02-01 12:11:45

answer

#include<bits/stdc++.h>
#define LL long long
using namespace std;

int T;
LL n,d;
LL f[1000005];

void solve()
{
	int dep;
	scanf("%lld%lld",&n,&d);
	LL L,R;
	R=n*(n-1)/2;
	L=f[n];
	printf("%s",(L<=d&&d<=R)?"YES\n":"NO\n");
}

int main()
{
	scanf("%d",&T);
	for(int i=1,dep=0;i<=1e6;i++){
		if(i>((1<<(dep+1))-1)) dep++;
		f[i]=f[i-1]+dep;
	}
	while(T--)
		solve();
}

Details

小提示:点击横条可展开更详细的信息

Test #1:

score: 10
Accepted
time: 0ms
memory: 9000kb

input:

10
8 19
5 5
7 35
7 48
9 19
8 16
6 41
7 17
9 91
4 2

output:

YES
NO
NO
NO
YES
YES
NO
YES
NO
NO

result:

ok 10 lines

Test #2:

score: 10
Accepted
time: 0ms
memory: 9004kb

input:

10
2 1
6 13
7 21
10 90
5 6
10 83
9 20
3 2
9 28
1 3

output:

YES
YES
YES
NO
YES
NO
YES
YES
YES
NO

result:

ok 10 lines

Test #3:

score: 10
Accepted
time: 0ms
memory: 9000kb

input:

10
9 102
10 45
6 43
9 14
7 11
9 78
8 27
7 12
7 5
10 38

output:

NO
YES
NO
NO
YES
NO
YES
YES
NO
YES

result:

ok 10 lines

Test #4:

score: 10
Accepted
time: 3ms
memory: 9004kb

input:

1000
120 6999
695 503854
504 368041
297 22428
598 127320
28 362
884 84188
959 252979
762 251557
648 ...

output:

YES
NO
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
NO
YES
NO
NO
YES
YES
YES
NO
YES
NO
YES
...

result:

ok 1000 lines

Test #5:

score: 10
Accepted
time: 0ms
memory: 9008kb

input:

1000
458 64274
981 387642
978 192180
669 28773
960 633139
820 723520
780 341590
839 598852
873 26191...

output:

YES
YES
YES
YES
NO
NO
NO
NO
YES
YES
YES
YES
YES
YES
NO
NO
YES
YES
YES
NO
YES
NO
YES
YES
YES
YES
YES
...

result:

ok 1000 lines

Test #6:

score: 10
Accepted
time: 5ms
memory: 9000kb

input:

1000
985 247962
535 120838
308 115653
741 49379
220 7726
911 39268
542 424900
655 319132
14 40
833 1...

output:

YES
YES
NO
YES
YES
YES
NO
NO
YES
YES
YES
YES
NO
YES
YES
NO
YES
YES
YES
YES
NO
YES
YES
YES
NO
YES
NO
...

result:

ok 1000 lines

Test #7:

score: 10
Accepted
time: 156ms
memory: 9004kb

input:

500000
534151 45724230847
968715 844087947893
735693 65839568930
991741 1445293168194
911481 2521104...

output:

YES
NO
YES
NO
YES
NO
NO
YES
YES
YES
YES
YES
NO
YES
YES
YES
NO
NO
YES
NO
YES
NO
NO
NO
YES
NO
YES
YES
...

result:

ok 500000 lines

Test #8:

score: 10
Accepted
time: 174ms
memory: 9000kb

input:

500000
696532 272632733915
931710 200334946963
841560 468554139891
208432 6029051249
592536 12784987...

output:

NO
YES
NO
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
NO
NO
NO
YES
YES...

result:

ok 500000 lines

Test #9:

score: 10
Accepted
time: 183ms
memory: 9004kb

input:

500000
986940 1010763473275
610168 479443726977
901850 307100006293
104919 4622319458
530425 1686486...

output:

NO
NO
YES
YES
NO
NO
NO
NO
YES
NO
YES
NO
YES
YES
NO
YES
NO
NO
YES
YES
NO
YES
NO
YES
YES
NO
NO
YES
YES...

result:

ok 500000 lines

Test #10:

score: 10
Accepted
time: 147ms
memory: 9000kb

input:

500000
617161 142041237814
937886 290028194593
845565 213152268488
568475 13774883703
115125 5497297...

output:

YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
NO
YES
NO
YES
YES
NO
NO
YES
YES
NO
YES
YES
NO
YES
YES
YES...

result:

ok 500000 lines