結果

問題 No.360 増加門松列
ユーザー FF256grhyFF256grhy
提出日時 2016-04-17 23:17:48
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 33 ms / 2,000 ms
コード長 833 bytes
コンパイル時間 157 ms
コンパイル使用メモリ 26,884 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-25 18:36:01
合計ジャッジ時間 1,489 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
4,380 KB
testcase_01 AC 33 ms
4,380 KB
testcase_02 AC 5 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 29 ms
4,380 KB
testcase_05 AC 31 ms
4,376 KB
testcase_06 AC 31 ms
4,380 KB
testcase_07 AC 31 ms
4,376 KB
testcase_08 AC 29 ms
4,380 KB
testcase_09 AC 29 ms
4,376 KB
testcase_10 AC 9 ms
4,376 KB
testcase_11 AC 3 ms
4,380 KB
testcase_12 AC 29 ms
4,380 KB
testcase_13 AC 6 ms
4,380 KB
testcase_14 AC 6 ms
4,380 KB
testcase_15 AC 27 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 5 ms
4,380 KB
testcase_18 AC 26 ms
4,376 KB
testcase_19 AC 26 ms
4,380 KB
testcase_20 AC 27 ms
4,376 KB
testcase_21 AC 26 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

int isK(int a, int b, int c) {
	return ( (a < b && b > c && a != c) || (a > b && b < c && a != c) );
}

int main() {
	int d[7], i, j;
	for(i = 0; i < 7; i++) { scanf("%d", &d[i]); }
	
	int p[7], flag;
	for(p[0] = 0; p[0] < 7; p[0]++) {
	for(p[1] = 0; p[1] < 7; p[1]++) {
	for(p[2] = 0; p[2] < 7; p[2]++) {
	for(p[3] = 0; p[3] < 7; p[3]++) {
	for(p[4] = 0; p[4] < 7; p[4]++) {
	for(p[5] = 0; p[5] < 7; p[5]++) {
	for(p[6] = 0; p[6] < 7; p[6]++) {
		flag = 0;
		for(i = 0; i < 7; i++) {
		for(j = 0; j < i; j++) {
			if(p[i] == p[j]) { flag = 1; break; }
		}
		}
		if(flag) { continue; }
		
		flag = 1;
		for(i = 0; i < 7 - 2; i++) {
			if( ! ( isK(d[p[i]], d[p[i+1]], d[p[i+2]]) && d[p[i]] < d[p[i+2]] ) ) { flag = 0; break; }
		}
		if(flag) { printf("YES\n"); return 0; }
	}}}}}}}
	
	printf("NO\n");
	return 0;
}
0