結果

問題 No.497 入れ子の箱
ユーザー gigimegigime
提出日時 2017-03-24 22:45:46
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 9 ms / 5,000 ms
コード長 964 bytes
コンパイル時間 2,000 ms
コンパイル使用メモリ 176,944 KB
実行使用メモリ 7,724 KB
最終ジャッジ日時 2023-09-20 01:52:43
合計ジャッジ時間 3,240 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 7 ms
7,460 KB
testcase_04 AC 8 ms
7,504 KB
testcase_05 AC 8 ms
7,436 KB
testcase_06 AC 8 ms
7,572 KB
testcase_07 AC 7 ms
7,508 KB
testcase_08 AC 7 ms
7,504 KB
testcase_09 AC 7 ms
7,520 KB
testcase_10 AC 7 ms
7,508 KB
testcase_11 AC 8 ms
7,504 KB
testcase_12 AC 9 ms
7,520 KB
testcase_13 AC 9 ms
7,564 KB
testcase_14 AC 9 ms
7,512 KB
testcase_15 AC 9 ms
7,560 KB
testcase_16 AC 9 ms
7,724 KB
testcase_17 AC 9 ms
7,584 KB
testcase_18 AC 7 ms
7,444 KB
testcase_19 AC 8 ms
7,592 KB
testcase_20 AC 8 ms
7,516 KB
testcase_21 AC 7 ms
7,504 KB
testcase_22 AC 8 ms
7,512 KB
testcase_23 AC 7 ms
7,656 KB
testcase_24 AC 7 ms
7,452 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 1 ms
4,384 KB
testcase_27 AC 9 ms
7,452 KB
testcase_28 AC 8 ms
7,524 KB
testcase_29 AC 8 ms
7,528 KB
testcase_30 AC 7 ms
7,528 KB
testcase_31 AC 8 ms
7,456 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
#define ALL(x) x.begin(),x.end()
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

int N;
const int M = 3;
int dp [1001] [1001];
const int INF = 1e9;

int main()
{
	scanf("%d",&N);
	vector< vector<int> > A(N,vector<int>(M));
	FOR(i,0,N){
		FOR(j,0,M){
			scanf("%d",&A [i] [j]);
		}
		sort(ALL(A [i]));
	}
	sort(ALL(A));
	reverse(ALL(A));

	fill(dp [0],dp [N + 1],-INF);
	FOR(i,0,N){
		dp [i + 1] [i] = 1;
	}
	FOR(i,1,N) FOR(j,0,i) if(dp [i] [j] >= 0){
		chmax(dp [i + 1] [j],dp [i] [j]);
		bool ok = true;
		FOR(k,0,M){
			ok &= A [j] [k] > A [i] [k];
		}
		if(ok){
			chmax(dp [i + 1] [i],dp [i] [j] + 1);
		}
	}

	int ans = 0;
	FOR(i,0,N){
		chmax(ans,dp [N] [i]);
	}
	printf("%d\n",ans);

	return 0;
}
0