Submission #673795

# Submission time Handle Problem Language Result Execution time Memory
673795 2022-12-22T04:22:26 Z sudheerays123 Lightning Rod (NOI18_lightningrod) C++17
7 / 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> 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(inside(a[i].first,a[i].second,a[j].first,a[j].second)){
				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;
}
# Verdict Execution time Memory Grader output
1 Execution timed out 2032 ms 262144 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 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 1 ms 324 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 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 1 ms 324 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Incorrect 1 ms 316 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 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 1 ms 324 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Incorrect 1 ms 316 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 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 1 ms 324 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Incorrect 1 ms 316 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2082 ms 262144 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2032 ms 262144 KB Time limit exceeded
2 Halted 0 ms 0 KB -