제출 #1322996

#제출 시각아이디문제언어결과실행 시간메모리
1322996aaaaaaaaAdvertisement 2 (JOI23_ho_t2)C++20
59 / 100
2093 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, 0); dp[0] = 1; for(int j = 0; j < n; ++j){ dp[j] = 1; for(int i = j - 1; i >= 0; --i){ if(v[i].second >= v[j].second){ dp[j] = 0; } } } int sum = 0; for(int j = 0; j < n; ++j) sum += dp[j]; cout << sum << "\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...