답안 #673797

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
673797 2022-12-22T04:35:50 Z sudheerays123 Lightning Rod (NOI18_lightningrod) C++17
40 / 100
2000 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);

	for(ll i = 1; i <= n; i++){

		ll last = INF;

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

		if(last == INF) last = n;
		left[i] = last;
	}

	vector<ll> dp(n+5);
	dp[1] = 1;

	for(ll i = 1; i <= n; i++){
		dp[i] = dp[i-1]+1;
		bool allinside = true;
		for(ll j = i-1; j >= 1; j--){
			if(left[j] >= i){
				dp[i] = min(dp[i],dp[j]);
			}

			if(inside(a[j].first,a[j].second,a[i].first,a[i].second) && allinside){
				dp[i] = min(dp[i],dp[j-1]+1);
			}
			else allinside = false;
		}
	}

	cout << dp[n];
}

int main(){

	fast;

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

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1505 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 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 320 KB Output is correct
7 Correct 1 ms 320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 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 320 KB Output is correct
7 Correct 1 ms 320 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 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 320 KB Output is correct
7 Correct 1 ms 320 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 4 ms 340 KB Output is correct
12 Correct 3 ms 420 KB Output is correct
13 Correct 3 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 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 320 KB Output is correct
7 Correct 1 ms 320 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 4 ms 340 KB Output is correct
12 Correct 3 ms 420 KB Output is correct
13 Correct 3 ms 340 KB Output is correct
14 Execution timed out 2051 ms 9584 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1399 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1505 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -