結果

問題 No.478 一般門松列列
ユーザー Mcpu3
提出日時 2018-09-29 13:51:03
言語 Java
(openjdk 23)
結果
AC  
実行時間 432 ms / 2,000 ms
コード長 757 bytes
コンパイル時間 2,158 ms
コンパイル使用メモリ 73,916 KB
実行使用メモリ 64,540 KB
最終ジャッジ日時 2024-10-12 08:14:44
合計ジャッジ時間 12,684 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

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