結果

問題 No.478 一般門松列列
ユーザー Mcpu3Mcpu3
提出日時 2018-09-29 13:51:03
言語 Java21
(openjdk 21)
結果
AC  
実行時間 422 ms / 2,000 ms
コード長 757 bytes
コンパイル時間 2,283 ms
コンパイル使用メモリ 74,068 KB
実行使用メモリ 50,220 KB
最終ジャッジ日時 2024-04-20 12:51:32
合計ジャッジ時間 12,704 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 139 ms
41,208 KB
testcase_01 AC 135 ms
41,344 KB
testcase_02 AC 136 ms
41,136 KB
testcase_03 AC 133 ms
41,416 KB
testcase_04 AC 132 ms
41,320 KB
testcase_05 AC 133 ms
41,348 KB
testcase_06 AC 136 ms
41,464 KB
testcase_07 AC 133 ms
41,360 KB
testcase_08 AC 133 ms
41,316 KB
testcase_09 AC 133 ms
41,208 KB
testcase_10 AC 131 ms
40,940 KB
testcase_11 AC 422 ms
50,156 KB
testcase_12 AC 395 ms
49,916 KB
testcase_13 AC 397 ms
49,956 KB
testcase_14 AC 389 ms
50,220 KB
testcase_15 AC 380 ms
49,744 KB
testcase_16 AC 281 ms
44,824 KB
testcase_17 AC 380 ms
49,980 KB
testcase_18 AC 324 ms
49,520 KB
testcase_19 AC 389 ms
50,008 KB
testcase_20 AC 364 ms
49,900 KB
testcase_21 AC 338 ms
49,796 KB
testcase_22 AC 315 ms
48,992 KB
testcase_23 AC 295 ms
48,804 KB
testcase_24 AC 319 ms
49,700 KB
testcase_25 AC 368 ms
50,040 KB
testcase_26 AC 247 ms
45,412 KB
testcase_27 AC 246 ms
44,904 KB
testcase_28 AC 195 ms
42,116 KB
testcase_29 AC 193 ms
41,780 KB
testcase_30 AC 321 ms
49,232 KB
testcase_31 AC 289 ms
48,476 KB
testcase_32 AC 285 ms
47,272 KB
testcase_33 AC 279 ms
48,212 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), k = sc.nextInt(), min = 0, max = 1000000000, tmp = 1;
        sc.close();
        for (int i = 0; i < n; ++i) {
            if (k > i) {
                System.out.print(min);
                ++min;
            }
            else {
                if (tmp == 1) {
                    System.out.print(min);
                    ++min;
                }
                else {
                    System.out.print(max);
                    --max;
                }
                tmp ^= 1;
            }
            if (i != n - 1) System.out.print(" ");
        }
    }
}
0