結果

問題 No.1703 Much Matching
ユーザー mkawa2mkawa2
提出日時 2021-10-08 22:50:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,201 bytes
コンパイル時間 4,326 ms
コンパイル使用メモリ 205,676 KB
実行使用メモリ 12,868 KB
最終ジャッジ日時 2023-09-30 11:59:49
合計ジャッジ時間 6,746 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 82 ms
8,068 KB
testcase_07 AC 6 ms
4,380 KB
testcase_08 AC 85 ms
7,864 KB
testcase_09 AC 98 ms
7,820 KB
testcase_10 AC 15 ms
4,380 KB
testcase_11 AC 21 ms
4,376 KB
testcase_12 AC 5 ms
4,376 KB
testcase_13 AC 37 ms
4,376 KB
testcase_14 AC 3 ms
4,376 KB
testcase_15 AC 17 ms
4,380 KB
testcase_16 AC 52 ms
5,092 KB
testcase_17 AC 61 ms
5,068 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 128 ms
7,952 KB
testcase_20 AC 16 ms
4,380 KB
testcase_21 AC 150 ms
7,384 KB
testcase_22 AC 57 ms
5,056 KB
testcase_23 AC 46 ms
5,076 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 7 ms
4,376 KB
testcase_26 AC 28 ms
4,376 KB
testcase_27 AC 65 ms
5,096 KB
testcase_28 AC 122 ms
7,348 KB
testcase_29 AC 23 ms
4,376 KB
testcase_30 AC 33 ms
4,376 KB
testcase_31 AC 4 ms
4,376 KB
testcase_32 WA -
testcase_33 AC 43 ms
5,096 KB
testcase_34 AC 5 ms
4,376 KB
testcase_35 AC 12 ms
4,376 KB
testcase_36 WA -
testcase_37 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

// #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;
}
0