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>
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ll long long
#define F first
#define S second
using namespace std;
const int N = 1e7 + 5, MOD = 1e9 + 7;
inline int readInt() {
int x = 0;
char ch = getchar();
while (ch < '0' || ch > '9') ch = getchar_unlocked();
while (ch >= '0' && ch <= '9'){
x = (x << 3) + (x << 1) + ch - '0';
ch = getchar_unlocked();
}
return x;
}
void solve(){
int n = readInt();
pair<int, int> a[n];
for(int i = 0; i < n; ++i){
a[i].S = readInt();
a[i].F = readInt();
}
sort(a, a + n, greater<pair<int, int> >());
pair<int, bool> dp[n];
dp[0].F = 1;
dp[0].S = 1;
for(int i = 1; i < n; ++i){
dp[i].F = dp[i - 1].F + 1;
dp[i].S = 1;
for(int j = i - 1; j >= 0; --j){
if(dp[j].S == 1 and a[j].F - a[i].F >= abs(a[j].S - a[i].S)){
dp[i].F = dp[i - 1].F;
dp[i].S = 0;
}
}
}
cout << dp[n - 1].F << '\n';
}
int main(){
fast;
int t = 1;
// cin >> t;
while(t--)
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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |