結果

問題 No.1366 交換門松列・梅
ユーザー ks2mks2m
提出日時 2021-01-29 21:35:10
言語 Java21
(openjdk 21)
結果
AC  
実行時間 134 ms / 1,000 ms
コード長 862 bytes
コンパイル時間 2,736 ms
コンパイル使用メモリ 77,908 KB
実行使用メモリ 41,744 KB
最終ジャッジ日時 2024-04-17 10:29:19
合計ジャッジ時間 5,075 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
41,400 KB
testcase_01 AC 133 ms
41,200 KB
testcase_02 AC 120 ms
40,228 KB
testcase_03 AC 132 ms
41,400 KB
testcase_04 AC 131 ms
41,420 KB
testcase_05 AC 133 ms
41,384 KB
testcase_06 AC 133 ms
41,744 KB
testcase_07 AC 132 ms
41,428 KB
testcase_08 AC 133 ms
41,640 KB
testcase_09 AC 132 ms
41,300 KB
testcase_10 AC 132 ms
41,148 KB
testcase_11 AC 134 ms
41,276 KB
testcase_12 AC 119 ms
40,224 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int[] a = new int[3];
		for (int i = 0; i < 3; i++) {
			a[i] = sc.nextInt();
		}
		int[] b = new int[3];
		for (int i = 0; i < 3; i++) {
			b[i] = sc.nextInt();
		}
		sc.close();

		if (check(a) && check(b)) {
			System.out.println("Yes");
			return;
		}
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				int t = a[i];
				a[i] = b[j];
				b[j] = t;
				if (check(a) && check(b)) {
					System.out.println("Yes");
					return;
				}
				t = a[i];
				a[i] = b[j];
				b[j] = t;
			}
		}
		System.out.println("No");
	}

	static boolean check(int[] a) {
		if (a[0] != a[2]) {
			if (a[0] < a[1] && a[1] > a[2]) return true;
			if (a[0] > a[1] && a[1] < a[2]) return true;
		}
		return false;
	}
}
0