QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#470353#2904. Tournament SeedingYGRXZYGRAC ✓32ms7448kbC++14820b2024-07-10 12:02:312024-07-10 12:02:32

Judging History

你现在查看的是最新测评结果

  • [2024-07-10 12:02:32]
  • 评测
  • 测评结果:AC
  • 用时:32ms
  • 内存:7448kb
  • [2024-07-10 12:02:31]
  • 提交

answer

#include <iostream>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;
typedef long long ll;
const int N =1e6 +5;
const int M = 1e9 +7;
const int inf = 0x3fffffff;
ll a[N];
ll quickpow(ll a,ll b){
	ll sum=1;
	while(b){
		if(b&1){
			sum=sum*a;
		}
		a=a*a;
		b>>=1;
	}
	return sum;
}
void solve(){
	ll n,k;
	cin>>n>>k;
	ll nn=quickpow(2,n);
	for(int i=1;i<=nn;i++){
		cin>>a[i];
	}
	sort(a+1,a+1+nn);
	ll l=1,r=nn;
	ll ss=0;
	while(l!=r){
		ll s=1;
		ll mid=(l+r)/2;
		for(ll i=mid+1;i<=r;i++){
			while(s<=mid&&a[i]-a[s]>k){
				s++;
			}
			if(s<=mid){
				ss++;
				s++;
			}
		}
		l=mid+1;
	}
	cout<<ss<<"\n";
}
int main() {
    ios::sync_with_stdio(0);cin.tie(0);
    //int t;cin>>t;while(t--)
    solve();
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3708kb

input:

2 2
9
1
6
4

output:

1

result:

ok single line: '1'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3712kb

input:

2 5
9
1
6
4

output:

3

result:

ok single line: '3'

Test #3:

score: 0
Accepted
time: 32ms
memory: 7224kb

input:

18 100000
63981058
402167968
705907849
905132088
764085359
766572732
394979339
587288537
687827781
374745622
433239185
210209598
656682739
33323609
544663716
664562693
780824772
242791998
265576314
269812925
916475203
586508739
838326754
593409259
886841510
372846951
839125238
768854826
478714951
43...

output:

310

result:

ok single line: '310'

Test #4:

score: 0
Accepted
time: 32ms
memory: 5772kb

input:

18 10000
331528
3861935
2861816
4953702
1266977
4997333
1159369
7060762
2012108
1453275
2881456
1433983
5941058
7255890
2897181
3937990
5191097
8656645
8895657
5890091
5398821
8204324
1362478
1146706
213176
3462031
7527889
7833258
5194890
4096582
1384078
309290
6530527
4649639
5240581
285945
3271153...

output:

2602

result:

ok single line: '2602'

Test #5:

score: 0
Accepted
time: 31ms
memory: 7448kb

input:

18 100000
630479
830129
598554
171285
897900
827825
63580
639155
754632
567938
167745
735275
57755
240229
863565
520928
812228
785938
909693
569971
830682
406690
811727
724734
81989
61888
842828
413749
558116
977583
202485
409524
930694
624619
230938
972709
806346
278276
463572
239863
639538
454221
...

output:

110852

result:

ok single line: '110852'

Test #6:

score: 0
Accepted
time: 29ms
memory: 7260kb

input:

18 10000000
579793
963299
461738
588015
937801
372663
30063
93049
180189
555161
397147
868900
283261
688836
222590
857485
47801
870237
672127
371938
490997
829296
140613
984919
327525
87549
66490
954984
520921
353858
339255
533207
522696
69383
701399
666757
954385
620448
319701
321371
103691
269083
...

output:

262143

result:

ok single line: '262143'

Test #7:

score: 0
Accepted
time: 0ms
memory: 3560kb

input:

1 1
1
3

output:

0

result:

ok single line: '0'