結果

問題 No.360 増加門松列
ユーザー mitsuomitsuo
提出日時 2016-05-04 17:13:38
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,258 bytes
コンパイル時間 2,267 ms
コンパイル使用メモリ 79,724 KB
実行使用メモリ 56,204 KB
最終ジャッジ日時 2024-04-15 11:23:43
合計ジャッジ時間 6,174 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 132 ms
54,232 KB
testcase_02 AC 132 ms
54,216 KB
testcase_03 AC 134 ms
54,124 KB
testcase_04 AC 132 ms
54,012 KB
testcase_05 AC 131 ms
54,408 KB
testcase_06 WA -
testcase_07 AC 132 ms
54,224 KB
testcase_08 AC 134 ms
54,384 KB
testcase_09 AC 132 ms
54,124 KB
testcase_10 AC 133 ms
54,068 KB
testcase_11 AC 131 ms
54,112 KB
testcase_12 WA -
testcase_13 AC 134 ms
53,972 KB
testcase_14 AC 131 ms
53,944 KB
testcase_15 AC 131 ms
54,080 KB
testcase_16 AC 136 ms
54,012 KB
testcase_17 AC 133 ms
53,912 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] input = new String[1];
		int i = 0;
		while (sc.hasNext()) {
			input[i] = sc.nextLine();
			i++;
		}
		String[] d = input[0].split(" ");
		int[] dl = new int[d.length];
		for (i = 0; i < d.length; i++) {
			dl[i] = Integer.valueOf(d[i]);
		}

		System.out.println(solve(dl));

		sc.close();
	}

	public static String solve(int[] d) {
		boolean result = false;
		Arrays.sort(d);
		int[] c1 = Arrays.copyOfRange(d, 0, d.length);
		int[] c2 = Arrays.copyOfRange(d, 0, d.length);
		swap(c1, 0, 1);
		swap(c1, 2, 3);
		swap(c1, 4, 4);

		swap(c2, 1, 2);
		swap(c2, 3, 4);
		swap(c2, 5, 6);

		result = isMatch(c1) || isMatch(c2);

		return result ? "YES" : "NO";
	}

	private static boolean isMatch(int[] c) {
		for (int i = 0; i + 2 < c.length; i++) {
			if (c[0] == c[1] || c[1] == c[2] || c[2] == c[0]) {
				return false;
			}
			if (c[0] > c[2]) {
				return false;
			}
			if ((c[0] < c[1] && c[1] < c[2]) || (c[2] < c[1] && c[1] < c[0])) {
				return false;
			}

		}
		return true;
	}

	private static void swap(int[] c, int i, int j) {
		int tmp = c[i];
		c[i] = c[j];
		c[j] = tmp;
	}
}
0