結果
| 問題 | 
                            No.1703 Much Matching
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2021-10-08 22:37:41 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 720 ms / 2,000 ms | 
| コード長 | 828 bytes | 
| コンパイル時間 | 2,065 ms | 
| コンパイル使用メモリ | 99,364 KB | 
| 最終ジャッジ日時 | 2025-01-24 22:51:12 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 35 | 
ソースコード
#include<iostream>
#include<atcoder/segtree>
#define fi first
#define se second
using namespace std;
using namespace atcoder;
using P = pair<int, int>;
int op(int x, int y) { return max(x, y);}
int e() { return -1;}
int main(){
  int N, M, Q; cin >> N >> M >> Q;
  vector<P> AB;
  for(int i=0; i<Q; ++i){
    int a, b; cin >> a >> b;
    AB.emplace_back(make_pair(a, b));
  }
  sort(AB.begin(), AB.end(), [](auto x, auto y){
    if(x.fi < y.fi) return true;
    if(x.fi > y.fi) return false;
    return x.se > y.se;
  });
  
  segtree<int, op, e> seg(max(N, M) + 1);
  vector<int> dp(max(N, M) + 1, -1);
  dp[0] = 0;
  seg.set(0, 0);
  
  for(auto& p: AB){
    int a, b; tie(a, b) = p;
    int x = seg.prod(0, b) + 1;
    dp[b] = x;
    seg.set(b, x);
  }
  
  int ANS = seg.all_prod();
  cout << ANS << endl;
  return 0;
}