結果
問題 | No.360 増加門松列 |
ユーザー |
![]() |
提出日時 | 2016-04-17 03:32:20 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 628 bytes |
コンパイル時間 | 634 ms |
コンパイル使用メモリ | 75,144 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-24 04:29:09 |
合計ジャッジ時間 | 1,307 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 22 |
ソースコード
#include <iostream>#include <vector>#include <algorithm>using namespace std;bool is_kadomatsu(int a, int b, int c){if(a==b || b==c || c==a) return false;if(a<b && b>c) return true;if(a>b && b<c) return true;return false;}int main(){int n = 7;vector<int> a(n);for(int i=0; i<n; i++) cin >> a[i];sort(a.begin(), a.end());do{bool ok = true;for(int i=2; i<n; i++){if( (is_kadomatsu(a[i-2], a[i-1], a[i]) && a[i-2] < a[i]) == false){ok = false;}}if(ok){cout << "YES" << endl;return 0;}}while(next_permutation(a.begin(), a.end()));cout << "NO" << endl;return 0;}