#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];
Sub2 *= max((i == 1), (E[i] == E[i - 1]));
}
if (Sub2){
map<int, int> C;
int ans = 0;
for (int i = 1; i <= n; i++){
C[X[i]]++;
ans += (C[X[i]] == 1);
}
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 time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |