結果
| 問題 |
No.1703 Much Matching
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2021-10-09 02:48:39 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.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 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 35 |
ソースコード
/* -*- 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;
}
tnakao0123