結果
問題 | No.497 入れ子の箱 |
ユーザー |
![]() |
提出日時 | 2025-02-21 20:39:51 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 7 ms / 5,000 ms |
コード長 | 803 bytes |
コンパイル時間 | 2,527 ms |
コンパイル使用メモリ | 208,240 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2025-02-21 20:39:55 |
合計ジャッジ時間 | 4,173 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
#include<bits/stdc++.h> #define int long long #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() using namespace std; template<typename T>istream&operator>>(istream&I,vector<T>&v){for(auto&i:v)I>>i;return I;} template<typename T>ostream&operator<<(ostream&O,vector<T>&v){for(auto&i:v)O<<i<<' ';return O;} namespace AC{ void solve(){ int N; cin>>N; vector<vector<int>>V; for(int i=0;i<N;i++){ vector<int>v(3); cin>>v; sort(all(v)); V.push_back(v); } sort(all(V)); vector<int>dp(N,1); int ans=1; for(int i=1;i<N;i++){ for(int j=0;j<i;j++){ bool flag=true; for(int k=0;k<3;k++){ if(V[j][k]>=V[i][k])flag=false; } if(flag)dp[i]=max(dp[i],dp[j]+1); } ans=max(ans,dp[i]); } cout<<ans; } } signed main(){ int t=1; //cin>>t; while(t--)AC::solve(); }