結果
| 問題 |
No.360 増加門松列
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-04-17 23:25:53 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 965 bytes |
| コンパイル時間 | 577 ms |
| コンパイル使用メモリ | 64,904 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-24 04:32:08 |
| 合計ジャッジ時間 | 1,266 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 22 |
ソースコード
#include <iostream>
#include <algorithm>
#include <vector>
int max3(int a, int b, int c){
return std::max(a, std::max(b, c));
}
int min3(int a, int b, int c){
return std::min(a, std::min(b, c));
}
bool diff3(int a, int b, int c){
return (a!=b && b!=c && c!=a);
}
bool isZoukaKadomatsu(int a, int b, int c){
return (diff3(a, b, c) && a<c && (b==max3(a, b, c) || b==min3(a, b, c)));
}
int main(){
std::ios::sync_with_stdio(false);
std::cin.tie(0);
std::vector<int> d(7);
for(auto& i : d){
std::cin >> i;
}
std::sort(d.begin(), d.end());
do{
bool flag=true;
for(int i=0; i<5; ++i){
if(!isZoukaKadomatsu(d[i], d[i+1], d[i+2])){
flag=false;
break;
}
}
if(flag){
std::cout << "YES\n";
return 0;
}
}while(std::next_permutation(d.begin(), d.end()));
std::cout << "NO\n";
return 0;
}