結果
問題 | No.1703 Much Matching |
ユーザー |
![]() |
提出日時 | 2021-10-08 22:15:04 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 370 ms / 2,000 ms |
コード長 | 1,362 bytes |
コンパイル時間 | 1,324 ms |
コンパイル使用メモリ | 120,940 KB |
最終ジャッジ日時 | 2025-01-24 22:22:34 |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 35 |
ソースコード
#include <iostream> #include <algorithm> #include <iomanip> #include <vector> #include <queue> #include <set> #include <map> #include <tuple> #include <cmath> #include <numeric> #include <functional> #include <cassert> #define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl; #define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } using namespace std; typedef long long ll; using P = pair<int, int>; const int INF = 1e9; int main(){ ios::sync_with_stdio(false); cin.tie(0); cout << setprecision(10) << fixed; int n, m, q; cin >> n >> m >> q; vector<int> a(q), b(q); vector<P> vp; for(int i = 0; i < q; i++) { cin >> a[i] >> b[i]; a[i]--; b[i]--; vp.push_back(P(a[i], -b[i])); } sort(vp.begin(), vp.end()); vector<int> dp(m+1, INF); dp[0] = -1; for(auto p: vp){ int x = -p.second; auto pt = lower_bound(dp.begin(), dp.end(), x); int i = pt-dp.begin(); dp[i] = x; } for(int i = m; i >= 0; i--){ if(dp[i] != INF){ cout << i << endl; return 0; } } }