結果

問題 No.1703 Much Matching
ユーザー tnakao0123tnakao0123
提出日時 2021-10-09 02:48:39
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 177 ms / 2,000 ms
コード長 863 bytes
コンパイル時間 250 ms
コンパイル使用メモリ 41,708 KB
実行使用メモリ 7,928 KB
最終ジャッジ日時 2023-09-30 18:44:12
合計ジャッジ時間 3,460 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,024 KB
testcase_01 AC 2 ms
5,020 KB
testcase_02 AC 2 ms
5,024 KB
testcase_03 AC 5 ms
7,152 KB
testcase_04 AC 5 ms
6,888 KB
testcase_05 AC 7 ms
7,360 KB
testcase_06 AC 49 ms
6,836 KB
testcase_07 AC 7 ms
7,688 KB
testcase_08 AC 57 ms
7,604 KB
testcase_09 AC 61 ms
7,696 KB
testcase_10 AC 12 ms
5,712 KB
testcase_11 AC 18 ms
7,608 KB
testcase_12 AC 5 ms
5,448 KB
testcase_13 AC 27 ms
7,544 KB
testcase_14 AC 3 ms
5,180 KB
testcase_15 AC 18 ms
7,724 KB
testcase_16 AC 33 ms
6,540 KB
testcase_17 AC 39 ms
7,716 KB
testcase_18 AC 2 ms
5,128 KB
testcase_19 AC 75 ms
7,548 KB
testcase_20 AC 10 ms
5,244 KB
testcase_21 AC 90 ms
7,824 KB
testcase_22 AC 43 ms
7,604 KB
testcase_23 AC 31 ms
7,836 KB
testcase_24 AC 2 ms
5,196 KB
testcase_25 AC 8 ms
6,404 KB
testcase_26 AC 25 ms
7,588 KB
testcase_27 AC 42 ms
7,864 KB
testcase_28 AC 82 ms
7,856 KB
testcase_29 AC 20 ms
7,496 KB
testcase_30 AC 26 ms
7,548 KB
testcase_31 AC 7 ms
7,608 KB
testcase_32 AC 46 ms
7,388 KB
testcase_33 AC 34 ms
7,628 KB
testcase_34 AC 5 ms
5,740 KB
testcase_35 AC 12 ms
7,520 KB
testcase_36 AC 177 ms
7,872 KB
testcase_37 AC 9 ms
7,928 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 1703.cc:  No.1703 Much Matching - yukicoder
 */

#include<cstdio>
#include<algorithm>

using namespace std;

/* constant */

const int MAX_N = 1000;
const int MAX_M = 1000;

/* typedef */

/* global variables */

bool ts[MAX_N][MAX_M];
int dp[MAX_N + 1][MAX_M + 1];

/* subroutines */

inline void setmax(int &a, int b) { if (a < b) a = b; }

/* main */

int main() {
  int n, m, q;
  scanf("%d%d%d", &n, &m, &q);

  for (int i = 0; i < q; i++) {
    int ai, bi;
    scanf("%d%d", &ai, &bi);
    ai--, bi--;
    ts[ai][bi] = true;
  }

  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= m; j++) {
      if (i < n && j < m && ts[i][j])
	setmax(dp[i + 1][j + 1], dp[i][j] + 1);
      if (i < n) 
	setmax(dp[i + 1][j], dp[i][j]);
      if (j < m) 
	setmax(dp[i][j + 1], dp[i][j]);
    }

  printf("%d\n", dp[n][m]);
  return 0;
}
0