# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
733885 | vjudge1 | Lightning Rod (NOI18_lightningrod) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
int t, n, m, ans, i, z,j, x, y;
cin >> n;
vector < pair < int, int > > v;
ans = 0;
for ( i = 1; i <= n; i ++) {
scanf("%d",& x);
scanf("%d",& y);
v.push_back(make_pair(2 * y, x - y));
}
sort ( v.begin(), v.end());
for ( i = v.size() - 1; i >= 0; i -- ) {
ans ++;
for ( j = i + 1; j <= (v.size() + i + 1)/2; j ++) {
p = v.size() - (j - i);
if ( v[j].second <= v[i].second && (v[j].second + v[j].first) >= (v[i].second + v[i].first)) {
ans --;
break;
}
if ( v[p].second <= v[p].second && (v[p].second + v[p].first) >= (v[i].second + v[i].first)) {
ans --;
break;
}
}
}
cout << ans << endl;
}