結果

問題 No.396 クラス替え
ユーザー kano_townkano_town
提出日時 2016-07-15 22:41:59
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 793 bytes
コンパイル時間 3,422 ms
コンパイル使用メモリ 74,468 KB
実行使用メモリ 257,712 KB
最終ジャッジ日時 2024-04-23 04:55:06
合計ジャッジ時間 5,943 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 108 ms
41,300 KB
testcase_01 AC 106 ms
41,180 KB
testcase_02 AC 108 ms
41,200 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 MLE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 AC 103 ms
41,060 KB
testcase_18 AC 108 ms
41,300 KB
testcase_19 AC 110 ms
41,064 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Yukicoder396 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int X = sc.nextInt();
        int Y = sc.nextInt();

        int[] g = new int[N];
        int m = 0;
        boolean up = true;
        for (int i = 0; i < N; i++) {
            g[i] = m;
            if (up) {
                m++;
                if (m >= M) {
                    m--;
                    up = false;
                }
            } else {
                m--;
                if (m < 0) {
                    m++;
                    up = true;
                }
            }
        }
        System.out.println(g[X - 1] == g[Y - 1] ? "YES" : "NO");
    }
}
0