結果

問題 No.497 入れ子の箱
ユーザー tnakao0123tnakao0123
提出日時 2017-04-01 18:04:19
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 5 ms / 5,000 ms
コード長 1,471 bytes
コンパイル時間 750 ms
コンパイル使用メモリ 88,592 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-22 02:06:30
合計ジャッジ時間 2,208 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 497.cc: No.497 入れ子の箱 - yukicoder
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 1000;

/* typedef */

struct Box {
  int x, y, z;
  Box() {}
  Box(int _x, int _y, int _z): x(_x), y(_y), z(_z) {}

  bool operator<(const Box &b) const {
    return x < b.x || (x == b.x && (y < b.y || (y == b.y && z < b.z)));
  }

  bool fit(const Box &b) const {
    return x < b.x && y < b.y && z < b.z;
  }

  void print() { printf("(%d,%d,%d)\n", x, y, z); }
};

/* global variables */

Box bs[MAX_N];
int dp[MAX_N];

/* subroutines */

inline void setmax(int &a, int b) { if (a < b) a = b; }

/* main */

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int ds[3];
    scanf("%d%d%d", ds, ds + 1, ds + 2);
    sort(ds, ds + 3);
    bs[i] = Box(ds[0], ds[1], ds[2]);
  }
  sort(bs, bs + n);
  //for (int i = 0; i < n; i++) bs[i].print();

  fill(dp, dp + n, 0);

  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++)
      if (bs[i].fit(bs[j])) setmax(dp[j], dp[i] + 1);

  int maxd = 0;
  for (int i = 0; i < n; i++) setmax(maxd, dp[i]);
  printf("%d\n", maxd + 1);
  return 0;
}
0