結果

問題 No.1366 交換門松列・梅
ユーザー xRS43BofaUEZ5gcxRS43BofaUEZ5gc
提出日時 2021-03-02 09:53:31
言語 Java21
(openjdk 21)
結果
AC  
実行時間 126 ms / 1,000 ms
コード長 1,168 bytes
コンパイル時間 3,455 ms
コンパイル使用メモリ 77,896 KB
実行使用メモリ 41,448 KB
最終ジャッジ日時 2024-04-17 10:34:36
合計ジャッジ時間 5,479 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
39,872 KB
testcase_01 AC 120 ms
41,044 KB
testcase_02 AC 123 ms
41,108 KB
testcase_03 AC 108 ms
40,100 KB
testcase_04 AC 114 ms
40,600 KB
testcase_05 AC 115 ms
40,080 KB
testcase_06 AC 126 ms
41,448 KB
testcase_07 AC 113 ms
40,092 KB
testcase_08 AC 119 ms
40,956 KB
testcase_09 AC 125 ms
40,980 KB
testcase_10 AC 125 ms
41,188 KB
testcase_11 AC 114 ms
40,084 KB
testcase_12 AC 122 ms
41,424 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class HelloWorld {

	    public static void main(String[] args) throws Exception {

	    	Scanner sc = new Scanner(System.in);
	    	int[] arr1 = new int[3];
	    	int[] arr2 = new int[3];
	        for (int i = 0 ;  i < 3; i ++) {
	        	arr1[i] = sc.nextInt();
	        }
	        for (int i = 0 ;  i < 3; i ++) {
	        	arr2[i] = sc.nextInt();
	        }
	        sc.close();

	        boolean flag = false;

	        for (int i = 0; i < 3; i ++) {
	        	if (flag == true) {break;}
	        	for (int j = 0; j < 3; j ++) {
	        		int temp = 0;
	        		temp = arr1[i];
	        		arr1[i] = arr2[j];
	        		arr2[j] = temp;
	        		if (is_matsu(arr1) && is_matsu(arr2)) {
	        			flag = true;
	        			break;
	        		}
	        		temp = arr1[i];
	        		arr1[i] = arr2[j];
	        		arr2[j] = temp;
	        	}
	        }

            
	        System.out.println(flag ?  "Yes" : "No");

	     }




	    static boolean is_matsu(int[] arr) {
	    	return (arr[0] < arr[1] && arr[2] < arr[1] && arr[0] != arr[2]) ||
	    			    (arr[0] > arr[1] && arr[2] > arr[1] && arr[0] != arr[2]);
	    }



	}
0