結果
問題 |
No.1703 Much Matching
|
ユーザー |
![]() |
提出日時 | 2021-10-08 22:50:35 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,201 bytes |
コンパイル時間 | 2,480 ms |
コンパイル使用メモリ | 201,600 KB |
最終ジャッジ日時 | 2025-01-24 23:04:18 |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 WA * 3 |
ソースコード
// #include <atcoder/all> // using namespace atcoder; #include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define all(x) (x).begin(), (x).end() using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; using vi = vector<int>; using vll = vector<ll>; using vvi = vector<vector<int>>; using vvll = vector<vector<ll>>; const int inf = 1e9; const ll lim = 1e18; int dx[] = {1, 1, 0, -1, -1, -1, 0, 1}; int dy[] = {0, 1, 1, 1, 0, -1, -1, -1}; int tree[1005]; void update(int i, int a) { i++; while (i < 1004) { tree[i] = max(tree[i], a); i += i & -i; } } int getmax(int i) { i++; int res = -inf; while (i > 0) { res = max(res, tree[i]); i -= i & -i; } return res; } int main() { cin.tie(0); ios::sync_with_stdio(false); rep(i, 1005) tree[i] = -inf; update(0,0); int n, m, q; cin >> n >> m >> q; vector<pair<int, int>> ab; rep(i, q) { int a, b; cin >> a >> b; ab.emplace_back(a, -b); } sort(ab.begin(), ab.end()); for (auto [a, b] : ab) { b = -b; int pre = getmax(b - 1); update(b, pre + 1); } int ans = getmax(1004); cout << ans << endl; return 0; }