結果
問題 | No.2796 Small Matryoshka |
ユーザー |
|
提出日時 | 2024-06-28 21:36:28 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 128 ms / 2,000 ms |
コード長 | 1,673 bytes |
コンパイル時間 | 2,439 ms |
コンパイル使用メモリ | 211,068 KB |
実行使用メモリ | 14,208 KB |
最終ジャッジ日時 | 2024-06-28 21:36:39 |
合計ジャッジ時間 | 3,839 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 1 ms
6,944 KB |
testcase_02 | AC | 2 ms
6,944 KB |
testcase_03 | AC | 2 ms
6,940 KB |
testcase_04 | AC | 0 ms
6,940 KB |
testcase_05 | AC | 12 ms
6,940 KB |
testcase_06 | AC | 65 ms
6,940 KB |
testcase_07 | AC | 2 ms
6,944 KB |
testcase_08 | AC | 49 ms
6,940 KB |
testcase_09 | AC | 111 ms
14,080 KB |
testcase_10 | AC | 113 ms
14,080 KB |
testcase_11 | AC | 128 ms
14,208 KB |
testcase_12 | AC | 36 ms
6,944 KB |
testcase_13 | AC | 6 ms
6,944 KB |
testcase_14 | AC | 32 ms
6,944 KB |
testcase_15 | AC | 10 ms
6,940 KB |
testcase_16 | AC | 17 ms
6,940 KB |
testcase_17 | AC | 73 ms
7,040 KB |
testcase_18 | AC | 84 ms
7,552 KB |
testcase_19 | AC | 24 ms
6,940 KB |
testcase_20 | AC | 35 ms
6,944 KB |
testcase_21 | AC | 73 ms
7,040 KB |
ソースコード
#include "bits/stdc++.h" using namespace std; #define all(x) x.begin(),x.end() template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << " " << p.second; } template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { string sep; for (const T &x : v) os << sep << x, sep = " "; return os; } #ifdef LOCAL #include "debug.h" #else #define debug(...) 42 #define ASSERT(...) 42 #endif typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int,int> pi; const int oo = 1e9; template<typename T> struct fenwick { int n; vector<T> fen; fenwick(){} fenwick(int nn) { fen.resize(nn+1); n = nn; } auto sum(int i) { T ans = 0; while(i) { ans=max(ans,fen[i]); i&=i-1; } return ans; } auto query(int r) { return sum(r+1); } void update(int i, T val) { ++i; while(i<=n) { fen[i]=max(fen[i],val); i+= i&(-i); } } }; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; vector<array<int,2>> rs(n); for(auto& [r,R] : rs) { cin >> r >> R; } sort(all(rs)); int res=0; multiset<int> s; int cur=0; for(auto [r,R] : rs) { auto it = s.upper_bound(r); if(it!=s.begin()) { --it; s.erase(it); } else cur++; s.insert(R); } cout << cur-1 << '\n'; }