結果

問題 No.478 一般門松列列
ユーザー tentententen
提出日時 2021-02-04 11:41:57
言語 Java21
(openjdk 21)
結果
AC  
実行時間 174 ms / 2,000 ms
コード長 922 bytes
コンパイル時間 2,293 ms
コンパイル使用メモリ 74,148 KB
実行使用メモリ 60,108 KB
最終ジャッジ日時 2023-09-13 06:32:41
合計ジャッジ時間 10,212 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
56,088 KB
testcase_01 AC 121 ms
55,856 KB
testcase_02 AC 121 ms
55,828 KB
testcase_03 AC 131 ms
53,800 KB
testcase_04 AC 122 ms
56,052 KB
testcase_05 AC 123 ms
56,172 KB
testcase_06 AC 121 ms
55,588 KB
testcase_07 AC 120 ms
56,132 KB
testcase_08 AC 122 ms
55,840 KB
testcase_09 AC 121 ms
56,328 KB
testcase_10 AC 120 ms
56,020 KB
testcase_11 AC 165 ms
58,112 KB
testcase_12 AC 173 ms
58,224 KB
testcase_13 AC 167 ms
58,280 KB
testcase_14 AC 171 ms
58,568 KB
testcase_15 AC 171 ms
58,288 KB
testcase_16 AC 148 ms
56,284 KB
testcase_17 AC 168 ms
58,132 KB
testcase_18 AC 168 ms
58,088 KB
testcase_19 AC 174 ms
58,184 KB
testcase_20 AC 170 ms
57,960 KB
testcase_21 AC 166 ms
60,108 KB
testcase_22 AC 163 ms
56,572 KB
testcase_23 AC 165 ms
55,988 KB
testcase_24 AC 163 ms
57,912 KB
testcase_25 AC 166 ms
58,584 KB
testcase_26 AC 132 ms
54,408 KB
testcase_27 AC 135 ms
56,096 KB
testcase_28 AC 128 ms
56,000 KB
testcase_29 AC 126 ms
55,844 KB
testcase_30 AC 163 ms
58,088 KB
testcase_31 AC 158 ms
55,772 KB
testcase_32 AC 146 ms
55,808 KB
testcase_33 AC 145 ms
56,192 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int count = n - k - 2;
        int left = 100000000;
        int right = 100000001;
        ArrayList<Integer> ans = new ArrayList<>();
        ans.add(left);
        ans.add(right);
        for (int i = 0; i < count; i++) {
            if (i % 2 == 0) {
                left--;
                ans.add(left);
            } else {
                right++;
                ans.add(right);
            }
        }
        while (ans.size() < n) {
            ans.add(left);
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            if (i > 0) {
                sb.append(" ");
            }
            sb.append(ans.get(i));
        }
        System.out.println(sb);
    }
}
0