結果

問題 No.360 増加門松列
ユーザー tkzw_21
提出日時 2016-06-29 15:31:33
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 587 bytes
コンパイル時間 1,605 ms
コンパイル使用メモリ 162,260 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-24 04:34:50
合計ジャッジ時間 1,986 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

bool is_kadomatu(int a1,int a2,int a3){
	if( a1 == a2 || a2 == a3 || a1 == a3 )return false;
	if( a2 > a1 && a2 > a3 || a2 < a1 && a2 < a3)return true;
	return false;
}

int main(void){
	vector<int> D(7);
	for(int i=0;i<7;i++){
		cin >> D[i];
	}

	sort(D.begin(),D.end());
	do{
		bool ok = true;
		for(int i=0;i<7-2;i++){
			if( !(is_kadomatu(D[i],D[i+1],D[i+2]) && D[i] < D[i+2] ))
				ok = false;
		}
		if(ok){
			cout << "YES" << endl;
			return 0;
		}
	}while(next_permutation(D.begin(),D.end()));

	cout << "NO" << endl;

	return 0;
}
0