結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 6 ms
6,944 KB
testcase_04 AC 5 ms
6,944 KB
testcase_05 AC 8 ms
6,944 KB
testcase_06 AC 51 ms
6,940 KB
testcase_07 AC 8 ms
7,756 KB
testcase_08 AC 59 ms
7,748 KB
testcase_09 AC 64 ms
7,040 KB
testcase_10 AC 12 ms
6,940 KB
testcase_11 AC 20 ms
6,944 KB
testcase_12 AC 5 ms
6,940 KB
testcase_13 AC 28 ms
6,940 KB
testcase_14 AC 3 ms
6,940 KB
testcase_15 AC 18 ms
7,168 KB
testcase_16 AC 34 ms
6,944 KB
testcase_17 AC 40 ms
7,760 KB
testcase_18 AC 3 ms
6,940 KB
testcase_19 AC 77 ms
7,632 KB
testcase_20 AC 11 ms
6,944 KB
testcase_21 AC 94 ms
7,936 KB
testcase_22 AC 43 ms
7,764 KB
testcase_23 AC 34 ms
7,552 KB
testcase_24 AC 3 ms
6,944 KB
testcase_25 AC 7 ms
6,944 KB
testcase_26 AC 24 ms
7,748 KB
testcase_27 AC 44 ms
7,680 KB
testcase_28 AC 84 ms
7,808 KB
testcase_29 AC 21 ms
7,748 KB
testcase_30 AC 27 ms
6,940 KB
testcase_31 AC 8 ms
6,940 KB
testcase_32 AC 46 ms
7,236 KB
testcase_33 AC 35 ms
7,876 KB
testcase_34 AC 6 ms
6,940 KB
testcase_35 AC 12 ms
7,748 KB
testcase_36 AC 176 ms
7,936 KB
testcase_37 AC 10 ms
7,936 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