답안 #674013

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
674013 2022-12-22T14:43:41 Z sudheerays123 Lightning Rod (NOI18_lightningrod) C++17
66 / 100
1494 ms 262144 KB
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
const ll N = 100+5 , INF = 1e18 , MOD = 1e9+7;

bool inside(ll x1 , ll y1 , ll x2 , ll y2){
	return (abs(x2-x1) <= (y2-y1));
}

void solve(){

	ll n;
	cin >> n;

	vector<pair<ll,ll>> a(n+5);
	for(ll i = 1; i <= n; i++) cin >> a[i].first >> a[i].second;

	vector<ll> left(n+5) , right(n+5);

	for(ll i = 1; i <= n; i++){
		for(ll j = i; j >= 1; j--){
			if(inside(a[j].first,a[j].second,a[i].first,a[i].second)) left[i] = j;
			else break;
		}
	}

	for(ll i = 1; i <= n; i++){
		for(ll j = i; j <= n; j++){
			if(inside(a[j].first,a[j].second,a[i].first,a[i].second)) right[i] = j;
			else break;
		}
	}

	set<pair<ll,ll>> s;
	for(ll i = 1; i <= n; i++) s.insert(make_pair(a[i].second,i));

	ll ans = 0;

	while(s.size()){

		auto it = s.end();
		it--;
		pair<ll,ll> u = (*(it));

		ans++;

		for(ll i = u.second+1; i <= right[u.second]; i++){
			if(s.count(make_pair(a[i].second,i))){
				s.erase(s.find(make_pair(a[i].second,i)));
			}
		}

		for(ll i = u.second-1; i >= left[u.second]; i--){
			if(s.count(make_pair(a[i].second,i))){
				s.erase(s.find(make_pair(a[i].second,i)));
			}
		}

		s.erase(it);
	}

	cout << ans;
}

int main(){

	fast;

	ll tc = 1;
	// cin >> tc;
	while(tc--) solve();

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1494 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 2 ms 212 KB Output is correct
9 Correct 1 ms 216 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 2 ms 212 KB Output is correct
9 Correct 1 ms 216 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 2 ms 468 KB Output is correct
12 Correct 2 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 2 ms 212 KB Output is correct
9 Correct 1 ms 216 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 2 ms 468 KB Output is correct
12 Correct 2 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 248 ms 21240 KB Output is correct
15 Correct 245 ms 22040 KB Output is correct
16 Correct 196 ms 20204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1355 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1494 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -