結果

問題 No.1013 〇マス進む
ユーザー htensaihtensai
提出日時 2020-03-24 15:29:30
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,129 ms / 2,000 ms
コード長 1,041 bytes
コンパイル時間 2,136 ms
コンパイル使用メモリ 74,092 KB
実行使用メモリ 109,156 KB
最終ジャッジ日時 2023-08-30 05:31:32
合計ジャッジ時間 47,309 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,824 KB
testcase_01 AC 125 ms
55,824 KB
testcase_02 AC 125 ms
55,768 KB
testcase_03 AC 169 ms
56,296 KB
testcase_04 AC 147 ms
55,740 KB
testcase_05 AC 157 ms
56,400 KB
testcase_06 AC 168 ms
55,712 KB
testcase_07 AC 178 ms
55,980 KB
testcase_08 AC 175 ms
56,720 KB
testcase_09 AC 192 ms
56,592 KB
testcase_10 AC 188 ms
56,292 KB
testcase_11 AC 153 ms
55,868 KB
testcase_12 AC 191 ms
56,564 KB
testcase_13 AC 231 ms
59,268 KB
testcase_14 AC 632 ms
82,176 KB
testcase_15 AC 907 ms
97,652 KB
testcase_16 AC 821 ms
92,176 KB
testcase_17 AC 581 ms
76,792 KB
testcase_18 AC 674 ms
82,216 KB
testcase_19 AC 482 ms
67,484 KB
testcase_20 AC 1,013 ms
104,136 KB
testcase_21 AC 562 ms
73,000 KB
testcase_22 AC 704 ms
83,936 KB
testcase_23 AC 365 ms
66,788 KB
testcase_24 AC 1,002 ms
108,280 KB
testcase_25 AC 1,009 ms
104,360 KB
testcase_26 AC 364 ms
64,768 KB
testcase_27 AC 539 ms
72,712 KB
testcase_28 AC 345 ms
64,448 KB
testcase_29 AC 1,027 ms
103,744 KB
testcase_30 AC 517 ms
72,120 KB
testcase_31 AC 763 ms
86,344 KB
testcase_32 AC 619 ms
81,224 KB
testcase_33 AC 659 ms
82,312 KB
testcase_34 AC 900 ms
94,488 KB
testcase_35 AC 889 ms
93,872 KB
testcase_36 AC 249 ms
59,376 KB
testcase_37 AC 250 ms
60,252 KB
testcase_38 AC 954 ms
97,112 KB
testcase_39 AC 481 ms
66,876 KB
testcase_40 AC 1,011 ms
95,224 KB
testcase_41 AC 389 ms
64,468 KB
testcase_42 AC 661 ms
81,084 KB
testcase_43 AC 490 ms
67,504 KB
testcase_44 AC 662 ms
81,860 KB
testcase_45 AC 606 ms
78,024 KB
testcase_46 AC 401 ms
64,680 KB
testcase_47 AC 631 ms
80,716 KB
testcase_48 AC 685 ms
84,140 KB
testcase_49 AC 943 ms
95,088 KB
testcase_50 AC 798 ms
86,212 KB
testcase_51 AC 764 ms
83,472 KB
testcase_52 AC 321 ms
62,348 KB
testcase_53 AC 368 ms
64,292 KB
testcase_54 AC 821 ms
94,040 KB
testcase_55 AC 419 ms
64,604 KB
testcase_56 AC 1,035 ms
99,928 KB
testcase_57 AC 810 ms
84,164 KB
testcase_58 AC 1,129 ms
108,852 KB
testcase_59 AC 1,066 ms
108,644 KB
testcase_60 AC 1,104 ms
108,716 KB
testcase_61 AC 1,042 ms
109,156 KB
testcase_62 AC 1,008 ms
109,128 KB
testcase_63 AC 125 ms
56,004 KB
testcase_64 AC 124 ms
55,908 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[] arr = new int[n];
        long[][] answers = new long[n][31];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
            answers[i][0] = arr[i];
        }
        for (int i = 1; i < 31; i++) {
            for (int j = 0; j < n; j++) {
                answers[j][i] = answers[j][i - 1] + answers[(int)((j + answers[j][i - 1]) % n)][i - 1];
            }
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            int x = k;
            long ans = i;
            for (int j = 30; j >= 0; j--) {
                if (x >= (1 << j)) {
                    ans += answers[(int)(ans % n)][j];
                    x -= (1 << j);
                }
            }
            ans++;
            sb.append(ans).append("\n");
        }
        System.out.print(sb);
    }
}
0