제출 #1281773

#제출 시각아이디문제언어결과실행 시간메모리
1281773muhammad-ahmadAdvertisement 2 (JOI23_ho_t2)C++20
23 / 100
2091 ms2744 KiB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define endl '\n'

void solve(){
	int n; cin >> n;
	int X[n + 1] = {}, E[n + 1] = {};
	
	bool Sub1 = 1, Sub2 = (n <= 16);
	
	for (int i = 1; i <= n; i++){
		cin >> X[i] >> E[i];
		if (i > 1 && E[i] != E[i - 1]) Sub2 = 0;
	}
	
	if (Sub2){
		map<int, int> C;
		int ans = 0;
		for (int i = 1; i <= n; i++){
			C[X[i]]++;
			if (C[X[i]] == 1) ans++;
		}
		cout << ans << endl;		
	}
	else if (Sub1){
		int ans = 16;
		for (int i = 1; i <= (1LL << n); i++){
			vector<int> x;
			for (int j = 0; j < n; j++){
				if ((i >> j) & 1) x.push_back(j + 1);
			}
			bool vis[n + 1] = {};
			for (auto j : x){
				for (int k = 1; k <= n; k++){
					if (abs(X[k] - X[j]) <= E[j] - E[k]) vis[k] = 1;
				}
			}
			
			int pos = 0;
			
			for (int j = 1; j <= n; j++) pos += vis[j];
			if (pos == n) ans = min(ans, (int)x.size());
		}
		cout << ans << endl;
	}
		
}

signed main(){
	int tc = 1;
	// cin >> tc;
	while (tc--){
		solve();
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...