結果
問題 | No.1013 〇マス進む |
ユーザー | tenten |
提出日時 | 2023-06-08 13:05:41 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 521 ms / 2,000 ms |
コード長 | 2,532 bytes |
コンパイル時間 | 3,538 ms |
コンパイル使用メモリ | 87,340 KB |
実行使用メモリ | 99,400 KB |
最終ジャッジ日時 | 2024-12-30 20:29:25 |
合計ジャッジ時間 | 27,678 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 74 ms
37,192 KB |
testcase_01 | AC | 73 ms
37,288 KB |
testcase_02 | AC | 70 ms
37,476 KB |
testcase_03 | AC | 88 ms
38,056 KB |
testcase_04 | AC | 76 ms
37,652 KB |
testcase_05 | AC | 85 ms
37,952 KB |
testcase_06 | AC | 85 ms
37,940 KB |
testcase_07 | AC | 94 ms
38,300 KB |
testcase_08 | AC | 94 ms
38,304 KB |
testcase_09 | AC | 94 ms
38,424 KB |
testcase_10 | AC | 87 ms
38,212 KB |
testcase_11 | AC | 79 ms
37,912 KB |
testcase_12 | AC | 90 ms
38,400 KB |
testcase_13 | AC | 126 ms
40,780 KB |
testcase_14 | AC | 323 ms
65,968 KB |
testcase_15 | AC | 409 ms
81,560 KB |
testcase_16 | AC | 394 ms
77,544 KB |
testcase_17 | AC | 308 ms
63,752 KB |
testcase_18 | AC | 370 ms
68,336 KB |
testcase_19 | AC | 269 ms
56,696 KB |
testcase_20 | AC | 462 ms
93,220 KB |
testcase_21 | AC | 319 ms
63,032 KB |
testcase_22 | AC | 396 ms
68,736 KB |
testcase_23 | AC | 216 ms
50,788 KB |
testcase_24 | AC | 517 ms
96,592 KB |
testcase_25 | AC | 496 ms
93,780 KB |
testcase_26 | AC | 219 ms
50,764 KB |
testcase_27 | AC | 352 ms
63,320 KB |
testcase_28 | AC | 227 ms
50,732 KB |
testcase_29 | AC | 474 ms
92,148 KB |
testcase_30 | AC | 297 ms
57,868 KB |
testcase_31 | AC | 387 ms
72,068 KB |
testcase_32 | AC | 335 ms
64,904 KB |
testcase_33 | AC | 362 ms
65,472 KB |
testcase_34 | AC | 431 ms
81,608 KB |
testcase_35 | AC | 379 ms
80,312 KB |
testcase_36 | AC | 140 ms
42,240 KB |
testcase_37 | AC | 134 ms
41,612 KB |
testcase_38 | AC | 440 ms
86,308 KB |
testcase_39 | AC | 272 ms
54,868 KB |
testcase_40 | AC | 471 ms
88,020 KB |
testcase_41 | AC | 223 ms
51,076 KB |
testcase_42 | AC | 345 ms
64,784 KB |
testcase_43 | AC | 289 ms
55,728 KB |
testcase_44 | AC | 368 ms
68,288 KB |
testcase_45 | AC | 350 ms
63,664 KB |
testcase_46 | AC | 239 ms
52,628 KB |
testcase_47 | AC | 345 ms
64,700 KB |
testcase_48 | AC | 362 ms
67,500 KB |
testcase_49 | AC | 416 ms
87,748 KB |
testcase_50 | AC | 392 ms
73,492 KB |
testcase_51 | AC | 387 ms
70,064 KB |
testcase_52 | AC | 182 ms
47,528 KB |
testcase_53 | AC | 212 ms
50,316 KB |
testcase_54 | AC | 401 ms
78,496 KB |
testcase_55 | AC | 239 ms
52,476 KB |
testcase_56 | AC | 463 ms
90,276 KB |
testcase_57 | AC | 416 ms
71,780 KB |
testcase_58 | AC | 509 ms
98,552 KB |
testcase_59 | AC | 512 ms
98,244 KB |
testcase_60 | AC | 521 ms
99,400 KB |
testcase_61 | AC | 434 ms
93,156 KB |
testcase_62 | AC | 453 ms
93,076 KB |
testcase_63 | AC | 68 ms
37,324 KB |
testcase_64 | AC | 70 ms
37,488 KB |
ソースコード
import java.io.*; import java.util.*; import java.util.stream.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); int k = sc.nextInt(); long[][] values = new long[30][n]; int[][] nexts = new int[30][n]; int[] idxes = new int[n]; long[] ans = new long[n]; for (int i = 0; i < n; i++) { int x = sc.nextInt(); nexts[0][i] = (i + x) % n; values[0][i] = x; idxes[i] = i; ans[i] = i + 1; } for (int i = 1; i < 30; i++) { for (int j = 0; j < n; j++) { nexts[i][j] = nexts[i - 1][nexts[i - 1][j]]; values[i][j] = values[i - 1][j] + values[i - 1][nexts[i - 1][j]]; } } for (int i = 29; i >= 0; i--) { if (k < (1 << i)) { continue; } k -= (1 << i); int[] pidxes = new int[n]; for (int j = 0; j < n; j++) { ans[j] += values[i][idxes[j]]; idxes[j] = nexts[i][idxes[j]]; } } System.out.println(String.join("\n", Arrays.stream(ans).mapToObj(String::valueOf).toArray(String[]::new))); } } class Utilities { static String arrayToLineString(Object[] arr) { return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n")); } static String arrayToLineString(int[] arr) { return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new)); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public int[] nextIntArray() throws Exception { return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray(); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }