結果
問題 | No.497 入れ子の箱 |
ユーザー |
![]() |
提出日時 | 2018-11-23 14:29:14 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 9 ms / 5,000 ms |
コード長 | 1,088 bytes |
コンパイル時間 | 2,035 ms |
コンパイル使用メモリ | 208,720 KB |
最終ジャッジ日時 | 2025-01-06 17:12:13 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
#include<bits/stdc++.h>using namespace std;using Int = long long;template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}//INSERT ABOVE HEREsigned main(){Int n;cin>>n;using T = tuple<Int, Int, Int>;vector<T> vt;for(Int i=0;i<n;i++){Int x,y,z;cin>>x>>y>>z;if(x<=y&&y>=z) swap(x,y);if(x<=z&&z>=y) swap(x,z);vt.emplace_back(x,y,z);}sort(vt.rbegin(),vt.rend());auto check=[&](Int x,Int y,Int z,Int a,Int b,Int c){if(x<a&&y<b&&z<c) return 1;if(x<a&&z<b&&y<c) return 1;if(y<a&&x<b&&z<c) return 1;if(y<a&&z<b&&x<c) return 1;if(z<a&&x<b&&y<c) return 1;if(z<a&&y<b&&x<c) return 1;return 0;};vector<Int> dp(n,1);for(Int i=0;i<n;i++){Int x,y,z;tie(x,y,z)=vt[i];for(Int j=0;j<i;j++){Int a,b,c;tie(a,b,c)=vt[j];if(check(x,y,z,a,b,c))chmax(dp[i],dp[j]+1);}}cout<<*max_element(dp.begin(),dp.end())<<endl;return 0;}