結果
問題 | No.360 増加門松列 |
ユーザー |
|
提出日時 | 2016-04-17 22:40:15 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 626 bytes |
コンパイル時間 | 1,437 ms |
コンパイル使用メモリ | 162,716 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-24 04:29:25 |
合計ジャッジ時間 | 2,286 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 22 |
ソースコード
#include <bits/stdc++.h> using namespace std; bool isKadomatsu(long long x, long long y, long long z) { if (x == y || y == z || x == z) return false; if (x > y && y < z && x < z) return true; if (x < y && y > z && x < z) return true; return false; } bool solve() { vector<int> a(7); for (int i = 0; i < 7; i++) { cin >> a[i]; } sort(a.begin(), a.end()); do { bool all = true; for (int i = 0; i < 5; i++) { all &= isKadomatsu(a[i], a[i + 1], a[i + 2]); } if (all) return true; } while (next_permutation(a.begin(), a.end())); return false; } int main() { cout << (solve() ? "YES" : "NO") << endl; }