結果
問題 |
No.2796 Small Matryoshka
|
ユーザー |
|
提出日時 | 2024-06-28 22:30:13 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,081 bytes |
コンパイル時間 | 3,377 ms |
コンパイル使用メモリ | 230,688 KB |
最終ジャッジ日時 | 2025-02-22 01:15:14 |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 8 WA * 11 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define INF (int)1e18 #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> //#define int long long mt19937_64 RNG(chrono::steady_clock::now().time_since_epoch().count()); void Solve() { int n; cin >> n; vector <pair<int, int>> a(n); for (auto &x : a){ cin >> x.second >> x.first; } ordered_set os; for (auto x : a){ os.insert(x.second); } sort(a.begin(), a.end()); int ans = 0; for (int i = 0; i < n; i++){ int l = 0, r = n; // everyone from l + 1 to i will not be able to interact with you // some additional > i elements may not be able to interact as well // who are they? // people with minimum < a[i].first while (l != r){ int mid = (l + r + 1) / 2; if (a[i].second >= a[mid].first){ l = mid; } else { r = mid - 1; } } if (l == 0 && a[i].second < a[0].first){ l--; } int v = (i - l - 1); os.erase(os.find(a[i].second)); // cout << v << " "; v += os.order_of_key(a[i].first - 1); // cout << v << "\n"; ans = max(ans, v); } cout << ans << "\n"; } int32_t main() { auto begin = std::chrono::high_resolution_clock::now(); ios_base::sync_with_stdio(0); cin.tie(0); int t = 1; // freopen("in", "r", stdin); // freopen("out", "w", stdout); // cin >> t; for(int i = 1; i <= t; i++) { //cout << "Case #" << i << ": "; Solve(); } auto end = std::chrono::high_resolution_clock::now(); auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin); cerr << "Time measured: " << elapsed.count() * 1e-9 << " seconds.\n"; return 0; }