답안 #1067083

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1067083 2024-08-20T11:02:53 Z AdamGS 송신탑 (IOI22_towers) C++17
17 / 100
823 ms 16336 KB
#include "towers.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const ll INF=1e18+7;
const int LIM=1e5+7;
ll T[LIM], jaki[LIM], n;
set<pair<ll,ll>>S, P;
vector<pair<ll,ll>>ans;
void dodaj(int x) {
	auto it=S.lower_bound({x, -1}); ++it;
	auto a=*it;
	P.insert({abs(T[x]-T[a.st]), x});
}
void usun(int x) {
	auto it=S.lower_bound({x, -1}); ++it;
	auto a=*it;
	P.erase({abs(T[x]-T[a.st]), x});
}
void init(int _n, vector<int>_H) {
	n=_n;
	rep(i, n) T[i+1]=_H[i];
	T[0]=T[n+1]=INF;
	int akt=2;
	jaki[0]=jaki[n+1]=1;
	rep(i, n) if((T[i]<T[i+1] && T[i+1]>T[i+2]) || (T[i]>T[i+1] && T[i+1]<T[i+2])) {
		jaki[i+1]=akt;
		akt^=3;
	}
	rep(i, n+2) if(jaki[i]) S.insert({i, jaki[i]});
	auto it=S.begin();
	while(true) {
		auto it2=it; ++it2;
		if(it2==S.end()) break;
		auto a=*it;
		dodaj(a.st);
		++it;
	}
	ans.pb({0, S.size()/2});
	while(P.size()>2) {
		auto a=*P.begin();
		usun(a.nd);
		auto it=S.lower_bound({a.nd, -1});
		++it;
		auto b=*it;
		usun(b.st);
		--it; --it;
		b=*it;
		usun(b.st);
		++it;
		S.erase(it);
		it=S.lower_bound({a.nd, -1});
		S.erase(it);
		it=S.lower_bound({a.nd, -1});
		--it;
		b=*it;
		dodaj(b.st);
		ans.pb({a.st, S.size()/2});
	}
}
int max_towers(int l, int r, int d) {
	int po=0, ko=ans.size()-1;
	while(po<ko) {
		int sr=(po+ko+1)/2;
		if(ans[sr].st<d) po=sr; else ko=sr-1;
	}
	return ans[po].nd;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 306 ms 1620 KB 1st lines differ - on the 1st token, expected: '1', found: '2'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '13', found: '131'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '13', found: '131'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 591 ms 12084 KB 1st lines differ - on the 1st token, expected: '11903', found: '33010'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 216 ms 3152 KB Output is correct
2 Correct 708 ms 12108 KB Output is correct
3 Correct 800 ms 12076 KB Output is correct
4 Correct 781 ms 16336 KB Output is correct
5 Correct 823 ms 16332 KB Output is correct
6 Correct 803 ms 16244 KB Output is correct
7 Correct 806 ms 16336 KB Output is correct
8 Correct 595 ms 1880 KB Output is correct
9 Correct 606 ms 1880 KB Output is correct
10 Correct 632 ms 1880 KB Output is correct
11 Correct 614 ms 1880 KB Output is correct
12 Correct 106 ms 12232 KB Output is correct
13 Correct 165 ms 16336 KB Output is correct
14 Correct 166 ms 16332 KB Output is correct
15 Correct 8 ms 1880 KB Output is correct
16 Correct 8 ms 1880 KB Output is correct
17 Correct 105 ms 11212 KB Output is correct
18 Correct 100 ms 12212 KB Output is correct
19 Correct 110 ms 12232 KB Output is correct
20 Correct 154 ms 16336 KB Output is correct
21 Correct 157 ms 16256 KB Output is correct
22 Correct 162 ms 16336 KB Output is correct
23 Correct 170 ms 16332 KB Output is correct
24 Correct 9 ms 1880 KB Output is correct
25 Correct 9 ms 1880 KB Output is correct
26 Correct 16 ms 1876 KB Output is correct
27 Correct 12 ms 1880 KB Output is correct
28 Correct 2 ms 600 KB Output is correct
29 Correct 2 ms 600 KB Output is correct
30 Correct 3 ms 704 KB Output is correct
31 Correct 1 ms 344 KB Output is correct
32 Correct 0 ms 344 KB Output is correct
33 Correct 1 ms 344 KB Output is correct
34 Correct 2 ms 600 KB Output is correct
35 Correct 2 ms 600 KB Output is correct
36 Correct 2 ms 600 KB Output is correct
37 Correct 2 ms 600 KB Output is correct
38 Correct 2 ms 600 KB Output is correct
39 Correct 2 ms 600 KB Output is correct
40 Correct 1 ms 344 KB Output is correct
41 Correct 1 ms 344 KB Output is correct
42 Correct 1 ms 344 KB Output is correct
43 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '13', found: '131'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 306 ms 1620 KB 1st lines differ - on the 1st token, expected: '1', found: '2'
2 Halted 0 ms 0 KB -