Submission #758701

# Submission time Handle Problem Language Result Execution time Memory
758701 2023-06-15T07:04:20 Z PoPularPlusPlus Advertisement 2 (JOI23_ho_t2) C++17
0 / 100
1 ms 328 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long 
#define pb(e) push_back(e)
#define sv(a) sort(a.begin(),a.end())
#define sa(a,n) sort(a,a+n)
#define mp(a,b) make_pair(a,b)
#define vf first
#define vs second
#define ar array
#define all(x) x.begin(),x.end()
const int inf = 0x3f3f3f3f;
const int mod = 1000000007; 
const double PI=3.14159265358979323846264338327950288419716939937510582097494459230;

mt19937_64 RNG(chrono::steady_clock::now().time_since_epoch().count());

bool remender(ll a , ll b){return a%b;}

bool can(int x , int e , int x1 , int e1){
	return (abs(x-x1) <= e1-e);
}

void solve(){
	int n;
	cin >> n;
	int arr[n] , a[n];
	for(int i = 0; i < n; i++)cin >> arr[i] >> a[i];
	
	int cnt[n];
	for(int i = 0; i < n; i++)cnt[i] = 2;
	
	stack<int> s;
	for(int i = 0; i < n; i++){
		while(s.size() && can(arr[s.top()],a[s.top()],arr[i],a[i])){
			cnt[s.top()]--;
			s.pop();
		}
		s.push(i);
	}
	
	while(s.size())s.pop();
	for(int i = n - 1; i >= 0; i--){
		while(s.size() && can(arr[s.top()],a[s.top()],arr[i],a[i])){
			cnt[s.top()]--;
			s.pop();
		}
		s.push(i);
	}
	int ans = 0;
	for(int i = 0; i < n; i++){
		if(cnt[i] == 2)ans++;
	}
	cout << ans << '\n';
}

int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
//freopen("deleg.in", "r", stdin);
//freopen("deleg.out", "w", stdout);
	//int t;cin >> t;while(t--)
	solve();
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 328 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 324 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 324 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 328 KB Output isn't correct
2 Halted 0 ms 0 KB -