Submission #1223579

#TimeUsernameProblemLanguageResultExecution timeMemory
1223579toast12Advertisement 2 (JOI23_ho_t2)C++20
0 / 100
109 ms7016 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; using namespace std; typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set; int main() { int n; cin >> n; vector<pair<int, int>> neg, pos; for (int i = 0; i < n; i++) { int x, e; cin >> x >> e; if (e-x <= 0) neg.push_back({e-x, e+x}); if (e-x >= 0) pos.push_back({e-x, e+x}); } sort(neg.begin(), neg.end()); reverse(neg.begin(), neg.end()); indexed_set s; int ans = 0; for (int i = 0; i < neg.size(); i++) { ans = max(ans, int(s.order_of_key(neg[i].second+1))+1); s.insert(neg[i].second); } s.clear(); sort(pos.begin(), pos.end()); for (int i = 0; i < pos.size(); i++) { ans = max(ans, int(s.order_of_key(pos[i].second+1))+1); s.insert(pos[i].second); } cout << ans << '\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...