結果

問題 No.497 入れ子の箱
ユーザー lapilapi
提出日時 2019-08-18 13:08:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 6 ms / 5,000 ms
コード長 1,231 bytes
コンパイル時間 1,388 ms
コンパイル使用メモリ 114,584 KB
実行使用メモリ 6,952 KB
最終ジャッジ日時 2024-04-08 23:52:52
合計ジャッジ時間 2,839 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 3 ms
6,944 KB
testcase_04 AC 4 ms
6,948 KB
testcase_05 AC 3 ms
6,944 KB
testcase_06 AC 3 ms
6,944 KB
testcase_07 AC 4 ms
6,948 KB
testcase_08 AC 4 ms
6,948 KB
testcase_09 AC 4 ms
6,948 KB
testcase_10 AC 4 ms
6,944 KB
testcase_11 AC 4 ms
6,944 KB
testcase_12 AC 5 ms
6,944 KB
testcase_13 AC 5 ms
6,944 KB
testcase_14 AC 6 ms
6,948 KB
testcase_15 AC 5 ms
6,948 KB
testcase_16 AC 6 ms
6,944 KB
testcase_17 AC 5 ms
6,948 KB
testcase_18 AC 4 ms
6,952 KB
testcase_19 AC 4 ms
6,944 KB
testcase_20 AC 4 ms
6,944 KB
testcase_21 AC 4 ms
6,948 KB
testcase_22 AC 4 ms
6,944 KB
testcase_23 AC 2 ms
6,948 KB
testcase_24 AC 3 ms
6,944 KB
testcase_25 AC 2 ms
6,944 KB
testcase_26 AC 2 ms
6,948 KB
testcase_27 AC 5 ms
6,944 KB
testcase_28 AC 5 ms
6,944 KB
testcase_29 AC 5 ms
6,948 KB
testcase_30 AC 3 ms
6,948 KB
testcase_31 AC 3 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include <iomanip>
#include <cmath>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60

int X[1009][3];
P A[1009];

int dp[1009]; // dp[i] : i番目のものが一番内側にあるときの最大個数

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N; cin >> N;
	for (int i = 0; i < N; i++) {
		int tmp[3];
		for (int j = 0; j < 3; j++) cin >> tmp[j];
		sort(tmp, tmp + 3);
		for (int j = 0; j < 3; j++) X[i][j] = tmp[j];
		A[i] = P(X[i][2], i);
	}
	sort(A, A + N, greater<P>());
	//for (int i = 0; i < N; i++) cout << A[i].second << " ";

	for (int i = 0; i < N; i++) {
		int now = A[i].second;
		int M = 1;
		for (int j = 0; j < i; j++) {
			int befo = A[j].second;
			if (X[now][0] < X[befo][0] && X[now][1] < X[befo][1] && X[now][2] < X[befo][2]) M = max(M, dp[j] + 1);
		}
		dp[i] = M;
	}

	int ans = 0;
	for (int i = 0; i < N; i++) ans = max(ans, dp[i]);
	cout << ans << endl;


	return 0;
}
0