結果
問題 | No.497 入れ子の箱 |
ユーザー | myanta |
提出日時 | 2017-06-30 10:00:38 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,113 bytes |
コンパイル時間 | 631 ms |
コンパイル使用メモリ | 46,976 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-04-15 06:42:22 |
合計ジャッジ時間 | 1,722 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 1 ms
6,944 KB |
testcase_02 | AC | 2 ms
6,944 KB |
testcase_03 | AC | 3 ms
6,944 KB |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | AC | 2 ms
6,944 KB |
testcase_24 | AC | 2 ms
6,944 KB |
testcase_25 | AC | 2 ms
6,940 KB |
testcase_26 | AC | 1 ms
6,940 KB |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | AC | 5 ms
6,940 KB |
testcase_31 | AC | 5 ms
6,940 KB |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:78:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 78 | scanf("%d%d%d", &x, &y, &z); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include<cstdio> #include<vector> #include<algorithm> using namespace std; using vi=vector<int>; using vvi=vector<vi>; using ll=long long; class box_t { int x, y, z; public: box_t(int x, int y, int z) { if(x>y) swap(x, y); if(x>z) swap(x, z); if(y>z) swap(y, z); this->x=x; this->y=y; this->z=z; } ll size(void) const { return (ll)x*y*z; } bool operator<(const box_t&rhs) const { return size()<rhs.size(); } bool greater(box_t& rhs) { return (x>rhs.x && y>rhs.y && z>rhs.z); } void print(void) { printf("%d %d %d\n", x, y, z); } }; int solve(vector<box_t>&b) { int n=b.size(); vector<int> dp(n, 1); for(int i=0;i<n;i++) { for(int j=0;j<i;j++) { if(b[i].greater(b[j])) { dp[i]=max(dp[i], dp[j]+1); } } } int ret=dp[0]; for(int i=1;i<n;i++) { ret=max(ret, dp[i]); } return ret; } int main(void) { int n; while(scanf("%d", &n)==1) { vector<box_t> b; for(int i=0;i<n;i++) { int x, y, z; scanf("%d%d%d", &x, &y, &z); b.push_back(box_t(x, y, z)); } sort(b.begin(), b.end()); printf("%d\n", solve(b)); } return 0; }