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;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long n;
cin >> n;
set<long long> st;
long long x[n], e[n];
for (long long i = 0; i < n; i++) cin >> x[i] >> e[i];
//long long s[n-1];
//for (long long i = 1; i < n; i++) s[i-1] = e[i-1]-e[i];
long long c[n];
long long t = 0;
for (long long i = 0; i < n; i++) {
for (long long j = 0; j < i; j++) {
if (abs(x[i]-x[j]) <= e[i]-e[j]) t++;
}
for (long long j = i+1; j < n; j++) {
if (abs(x[i]-x[j]) <= e[i]-e[j]) t++;
}
c[i] = t+1;
t = 0;
}
sort(c, c+n, greater<int>());
long long as = 0;
long long i = 0;
for (i = 0; i < n; i++) {
as += c[i];
//cout << i << " ";
if (as >= n) break;
}
//for (long long i: c) cout << i << " ";
cout << i+1;
}
# | 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... |