結果

問題 No.2796 Small Matryoshka
ユーザー Nzt3Nzt3
提出日時 2024-06-28 22:54:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 125 ms / 2,000 ms
コード長 681 bytes
コンパイル時間 2,015 ms
コンパイル使用メモリ 209,992 KB
実行使用メモリ 14,208 KB
最終ジャッジ日時 2024-06-28 22:54:18
合計ジャッジ時間 3,915 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 10 ms
6,944 KB
testcase_06 AC 56 ms
6,940 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 47 ms
6,944 KB
testcase_09 AC 119 ms
14,208 KB
testcase_10 AC 122 ms
14,208 KB
testcase_11 AC 125 ms
14,208 KB
testcase_12 AC 34 ms
6,944 KB
testcase_13 AC 5 ms
6,940 KB
testcase_14 AC 29 ms
6,944 KB
testcase_15 AC 9 ms
6,944 KB
testcase_16 AC 14 ms
6,948 KB
testcase_17 AC 64 ms
6,940 KB
testcase_18 AC 73 ms
7,552 KB
testcase_19 AC 22 ms
6,940 KB
testcase_20 AC 30 ms
6,940 KB
testcase_21 AC 63 ms
7,040 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/fenwicktree>
using namespace std;
using ll=long long;
constexpr int MOD=998244353;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define replr(i,l,r) for(int i=(l);i<(int)(r);i++)

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin>>N;
  vector A(N,array<int,2>());
  for(auto &i:A)cin>>i[0]>>i[1];
  sort(A.begin(),A.end(),[](array<int,2>& a,array<int,2>& b){
    return a[1]<b[1];
  });
  multiset<int,greater<int>>ans;
  ans.insert(0);
  for(int i=0;i<N;i++){
    auto it=ans.lower_bound(A[i][0]);
    if(it!=ans.end()){
      ans.erase(it);
    }
    ans.insert(A[i][1]);
  }
  cout<<(int)ans.size()-1<<'\n';
}
0