結果

問題 No.1090 ソーシャルディスタンス / Social Distance
ユーザー tentententen
提出日時 2020-12-07 09:54:03
言語 Java21
(openjdk 21)
結果
AC  
実行時間 589 ms / 2,000 ms
コード長 558 bytes
コンパイル時間 3,965 ms
コンパイル使用メモリ 74,416 KB
実行使用メモリ 64,600 KB
最終ジャッジ日時 2023-10-17 15:59:37
合計ジャッジ時間 17,763 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 135 ms
57,660 KB
testcase_01 AC 133 ms
57,492 KB
testcase_02 AC 492 ms
64,080 KB
testcase_03 AC 272 ms
61,264 KB
testcase_04 AC 510 ms
64,108 KB
testcase_05 AC 239 ms
60,444 KB
testcase_06 AC 541 ms
64,128 KB
testcase_07 AC 430 ms
61,736 KB
testcase_08 AC 560 ms
64,500 KB
testcase_09 AC 417 ms
60,880 KB
testcase_10 AC 510 ms
64,096 KB
testcase_11 AC 583 ms
64,436 KB
testcase_12 AC 468 ms
61,812 KB
testcase_13 AC 477 ms
62,072 KB
testcase_14 AC 575 ms
64,156 KB
testcase_15 AC 504 ms
64,108 KB
testcase_16 AC 381 ms
61,756 KB
testcase_17 AC 209 ms
59,960 KB
testcase_18 AC 389 ms
61,756 KB
testcase_19 AC 440 ms
62,044 KB
testcase_20 AC 411 ms
61,732 KB
testcase_21 AC 455 ms
61,760 KB
testcase_22 AC 135 ms
57,320 KB
testcase_23 AC 135 ms
57,572 KB
testcase_24 AC 589 ms
64,600 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 d = sc.nextInt();
        int[] arr = new int[n];
        int[] ans = new int[n];
        StringBuilder sb = new StringBuilder();
        sb.append(0);
        for (int i = 1; i < n; i++) {
            arr[i] = sc.nextInt() + arr[i - 1];
            ans[i] = Math.max(arr[i], ans[i - 1] + d);
            sb.append(" ").append(ans[i]);
        }
        System.out.println(sb);
    }
}
0