結果

問題 No.497 入れ子の箱
ユーザー srup٩(๑`н´๑)۶srup٩(๑`н´๑)۶
提出日時 2017-03-24 23:21:52
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 10 ms / 5,000 ms
コード長 1,884 bytes
コンパイル時間 1,681 ms
コンパイル使用メモリ 161,028 KB
実行使用メモリ 7,604 KB
最終ジャッジ日時 2023-09-20 03:48:47
合計ジャッジ時間 3,208 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
7,336 KB
testcase_01 AC 5 ms
7,480 KB
testcase_02 AC 4 ms
7,312 KB
testcase_03 AC 8 ms
7,392 KB
testcase_04 AC 8 ms
7,340 KB
testcase_05 AC 8 ms
7,388 KB
testcase_06 AC 8 ms
7,344 KB
testcase_07 AC 7 ms
7,348 KB
testcase_08 AC 8 ms
7,348 KB
testcase_09 AC 8 ms
7,352 KB
testcase_10 AC 8 ms
7,380 KB
testcase_11 AC 8 ms
7,336 KB
testcase_12 AC 10 ms
7,440 KB
testcase_13 AC 9 ms
7,436 KB
testcase_14 AC 10 ms
7,372 KB
testcase_15 AC 9 ms
7,424 KB
testcase_16 AC 10 ms
7,336 KB
testcase_17 AC 10 ms
7,376 KB
testcase_18 AC 8 ms
7,356 KB
testcase_19 AC 8 ms
7,376 KB
testcase_20 AC 8 ms
7,492 KB
testcase_21 AC 8 ms
7,484 KB
testcase_22 AC 8 ms
7,424 KB
testcase_23 AC 7 ms
7,388 KB
testcase_24 AC 7 ms
7,492 KB
testcase_25 AC 5 ms
7,328 KB
testcase_26 AC 4 ms
7,316 KB
testcase_27 AC 9 ms
7,336 KB
testcase_28 AC 8 ms
7,516 KB
testcase_29 AC 9 ms
7,340 KB
testcase_30 AC 8 ms
7,424 KB
testcase_31 AC 8 ms
7,604 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int N;
int X[1010], Y[1010], Z[1010];
int dp[1010][1010]; //i番目まで見て最後に使ったのがj

int main(void){
	cin >> N;
	X[0] = Y[0] = Z[0] = 0;
	reps(i, 1, N+1) cin >> X[i] >> Y[i] >> Z[i];
	int ret = 0;
	vector<tuple<int, int, int> > v;
	rep(i, N + 1){
		vector<int> t = {X[i], Y[i], Z[i]};
		sort(all(t));
		v.pb(make_tuple(t[0], t[1], t[2]));
	}
	sort(all(v));
	rep(i, v.size()){
		int x, y, z; tie(x, y, z) = v[i];
		X[i] = x, Y[i] = y, Z[i] = z;
		// printf("%d %d %d\n", X[i], Y[i], Z[i]);
	}
	/*
	int a = 0, b = 0, c = 0;
	rep(i, N){
		int x, y, z; tie(x, y, z) = v[i];
		// printf("%d %d %d\n", x, y, z);
		// printf("%d %d %d\n", a, b, c);
		if(a < x && b < y && c < z){
			ret++;
			a = x, b = y, c = z;
		}
	}
	*/
	rep(i, 1010)rep(j, 1010) dp[i][j] = -1;
	dp[0][0] = 0;
	rep(i, N)rep(j, N){ //j番目を最後に使った
		if(j > i) continue;
		if(dp[i][j] == -1)  continue;
		chmax(dp[i + 1][j], dp[i][j]); //i + 1を使わない
		// printf("%d %d\n", i, j);
		if(X[j] < X[i + 1] && Y[j] < Y[i + 1] && Z[j] < Z[i + 1]){
			// printf("2: %d %d\n", i, j);
			chmax(dp[i + 1][i + 1], dp[i][j] + 1);
		}
	}
	rep(i, 1010){
		chmax(ret, dp[N][i]);
	}
	cout << ret << endl;
	return 0;
}
0