結果

問題 No.497 入れ子の箱
ユーザー vjudge1
提出日時 2025-02-22 15:34:10
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 6 ms / 5,000 ms
コード長 929 bytes
コンパイル時間 2,838 ms
コンパイル使用メモリ 175,628 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2025-02-22 15:34:15
合計ジャッジ時間 3,752 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;
const int N = 1010;
int n;
int main(int argc, char const *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cin >> n;
    vector<vector<int>> a;
    for (int i = 1; i <= n; i++)
    {
        vector<int> vec(3);
        cin >> vec[0] >> vec[1] >> vec[2];
        sort(vec.begin(), vec.end());
        a.push_back(vec);
    }
    sort(a.begin(), a.end());
    vector<int> f(n, 1);
    f[0] = 1;
    for (int i = 1; i < n; i++)
        for (int j = 0; j < i; j++)
        {
            bool flag = 1;
            for (int k = 0; k < 3; k++)
                if (a[j][k] >= a[i][k])
                    flag = 0;
            if (flag)
                f[i] = max(f[i], f[j] + 1);
        }
    int ans = 0;
    for (int i = 0; i < n; i++)
        ans = max(ans, f[i]);
    cout << ans << endl;
    return 0;
}
0