Submission #835044

# Submission time Handle Problem Language Result Execution time Memory
835044 2023-08-23T06:51:31 Z ttamx Radio Towers (IOI22_towers) C++17
17 / 100
763 ms 14440 KB
#include "towers.h"
#include<bits/stdc++.h>

using namespace std;

const int N=1e5+5;
const int LG=17;
const int inf=2e9;

int n;
int h[N],spmx[LG][N],spmn[LG][N];
vector<int> vec;

int rmxq(int l,int r){
	int k=31-__builtin_clz(r-l+1);
	return max(spmx[k][l],spmx[k][r-(1<<k)+1]);
}

int rmnq(int l,int r){
	int k=31-__builtin_clz(r-l+1);
	return min(spmn[k][l],spmn[k][r-(1<<k)+1]);
}

void init(int N,vector<int> H){
	n=N;
	for(int i=1;i<=n;i++)h[i]=H[i-1];
	h[0]=h[n+1]=inf;
	for(int i=0;i<=n+1;i++)spmx[0][i]=spmn[0][i]=h[i];
	for(int i=1;i<LG;i++){
		for(int j=0;j+(1<<i)-1<=n+1;j++){
			spmx[i][j]=max(spmx[i-1][j],spmx[i-1][j+(1<<(i-1))]);
			spmn[i][j]=min(spmn[i-1][j],spmn[i-1][j+(1<<(i-1))]);
		}
	}
	auto lb=[&](int id){
		int l=0,r=id-1;
		while(l<r){
			int m=(l+r+1)/2;
			if(rmnq(m,id)<h[id])l=m;
			else r=m-1;
		}
		return l;
	};
	auto ub=[&](int id){
		int l=id+1,r=n+1;
		while(l<r){
			int m=(l+r)/2;
			if(rmnq(id,m)<h[id])r=m;
			else l=m+1;
		}
		return l;
	};
	for(int i=1;i<=n;i++){
		int l=lb(i),r=ub(i);
		int d=min(rmxq(l,i),rmxq(i,r))-h[i];
		vec.emplace_back(d);
	}
	sort(vec.begin(),vec.end());
}

int max_towers(int L,int R,int D){
	L++,R++;
	return n-(lower_bound(vec.begin(),vec.end(),D)-vec.begin());
}
# Verdict Execution time Memory Grader output
1 Incorrect 298 ms 8392 KB 1st lines differ - on the 1st token, expected: '1', found: '2'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB 1st lines differ - on the 1st token, expected: '13', found: '131'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB 1st lines differ - on the 1st token, expected: '13', found: '131'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 463 ms 14392 KB 1st lines differ - on the 1st token, expected: '11903', found: '33010'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 179 ms 3408 KB Output is correct
2 Correct 685 ms 14392 KB Output is correct
3 Correct 681 ms 14388 KB Output is correct
4 Correct 636 ms 14368 KB Output is correct
5 Correct 646 ms 14404 KB Output is correct
6 Correct 759 ms 14404 KB Output is correct
7 Correct 612 ms 14388 KB Output is correct
8 Correct 629 ms 14376 KB Output is correct
9 Correct 597 ms 14384 KB Output is correct
10 Correct 678 ms 14364 KB Output is correct
11 Correct 763 ms 14372 KB Output is correct
12 Correct 30 ms 14404 KB Output is correct
13 Correct 37 ms 14364 KB Output is correct
14 Correct 30 ms 14348 KB Output is correct
15 Correct 31 ms 14364 KB Output is correct
16 Correct 28 ms 14372 KB Output is correct
17 Correct 28 ms 13980 KB Output is correct
18 Correct 30 ms 14440 KB Output is correct
19 Correct 30 ms 14372 KB Output is correct
20 Correct 30 ms 14388 KB Output is correct
21 Correct 31 ms 14364 KB Output is correct
22 Correct 29 ms 14400 KB Output is correct
23 Correct 30 ms 14428 KB Output is correct
24 Correct 26 ms 14368 KB Output is correct
25 Correct 26 ms 14372 KB Output is correct
26 Correct 29 ms 14384 KB Output is correct
27 Correct 26 ms 14392 KB Output is correct
28 Correct 1 ms 592 KB Output is correct
29 Correct 1 ms 592 KB Output is correct
30 Correct 1 ms 592 KB Output is correct
31 Correct 1 ms 592 KB Output is correct
32 Correct 1 ms 592 KB Output is correct
33 Correct 1 ms 464 KB Output is correct
34 Correct 1 ms 592 KB Output is correct
35 Correct 1 ms 592 KB Output is correct
36 Correct 1 ms 592 KB Output is correct
37 Correct 1 ms 592 KB Output is correct
38 Correct 1 ms 592 KB Output is correct
39 Correct 1 ms 592 KB Output is correct
40 Correct 1 ms 592 KB Output is correct
41 Correct 1 ms 592 KB Output is correct
42 Correct 1 ms 592 KB Output is correct
43 Correct 1 ms 592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB 1st lines differ - on the 1st token, expected: '13', found: '131'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 298 ms 8392 KB 1st lines differ - on the 1st token, expected: '1', found: '2'
2 Halted 0 ms 0 KB -