제출 #1322975

#제출 시각아이디문제언어결과실행 시간메모리
1322975aaaaaaaaAdvertisement 2 (JOI23_ho_t2)C++20
0 / 100
2094 ms3452 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define all(x) x.begin(), x.end() const int inf = 1e18; signed main(){ ios::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr); int n; cin >> n; vector<pair<int, int>> v; for(int i = 1, x, e; i <= n; ++i){ cin >> x >> e; v.push_back({x - e, x + e}); } // xi - xj <= ei - ej // xi - ei <= xj - ej // xi + ei >= ej + xj sort(all(v), [&](pair<int, int> x, pair<int, int> y){ if(x.first == y.first) return x.second > y.second; return x.first < y.first; }); //v.erase(unique(v.begin(), v.end()), v.end()); vector<int> dp(n + 5, 1); for(int i = 0; i < n; ++i){ for(int j = i - 1; j >= 0; --j){ if(v[j].second < v[i].second){ dp[i] = max(dp[i], dp[j] + 1); } } } cout << *max_element(all(dp)) << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...