結果

問題 No.1090 ソーシャルディスタンス / Social Distance
ユーザー xRS43BofaUEZ5gc
提出日時 2021-03-29 14:07:33
言語 Java
(openjdk 23)
結果
AC  
実行時間 1,510 ms / 2,000 ms
コード長 537 bytes
コンパイル時間 3,477 ms
コンパイル使用メモリ 77,884 KB
実行使用メモリ 59,316 KB
最終ジャッジ日時 2024-11-29 09:48:11
合計ジャッジ時間 27,619 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;


public class HelloWorld {
		public static void main (String[] args) {
			Scanner sc = new Scanner(System.in);
			int n = sc.nextInt();
			int d = sc.nextInt();
			int[] ai = new int[n];
			ai[0] = 0;
			for (int i = 1;i < n; i ++) {
				ai[i] = ai[i - 1] + sc.nextInt();

			}
			sc.close();

			for (int i = 0; i < n; i ++) {
				if (i > 0 && ai[i] < ai[i - 1] + d) {
					ai[i] = ai[i - 1] + d;
				}
				System.out.print(ai[i]);
				if (i == n - 1) {
					break;
				}
				System.out.print(" ");
			}

	}
}
0