結果

問題 No.1090 ソーシャルディスタンス / Social Distance
ユーザー RISE70226821RISE70226821
提出日時 2020-08-04 12:58:07
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,126 ms / 2,000 ms
コード長 696 bytes
コンパイル時間 2,248 ms
コンパイル使用メモリ 73,336 KB
実行使用メモリ 69,120 KB
最終ジャッジ日時 2023-10-12 14:54:51
合計ジャッジ時間 22,656 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 137 ms
56,092 KB
testcase_01 AC 133 ms
56,092 KB
testcase_02 AC 901 ms
66,064 KB
testcase_03 AC 377 ms
60,800 KB
testcase_04 AC 952 ms
66,904 KB
testcase_05 AC 339 ms
61,336 KB
testcase_06 AC 1,067 ms
66,964 KB
testcase_07 AC 746 ms
65,372 KB
testcase_08 AC 1,072 ms
67,452 KB
testcase_09 AC 778 ms
65,456 KB
testcase_10 AC 884 ms
65,592 KB
testcase_11 AC 1,126 ms
65,672 KB
testcase_12 AC 787 ms
65,200 KB
testcase_13 AC 796 ms
65,484 KB
testcase_14 AC 1,065 ms
66,908 KB
testcase_15 AC 927 ms
67,192 KB
testcase_16 AC 605 ms
62,252 KB
testcase_17 AC 274 ms
59,260 KB
testcase_18 AC 613 ms
63,684 KB
testcase_19 AC 734 ms
65,164 KB
testcase_20 AC 678 ms
66,288 KB
testcase_21 AC 772 ms
65,316 KB
testcase_22 AC 138 ms
55,924 KB
testcase_23 AC 136 ms
55,540 KB
testcase_24 AC 1,126 ms
69,120 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		// 入力
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int D = sc.nextInt();
		int[] pos = new int[N];
		pos[0] = 0;
		for(int i = 1; i < N; i++){
			int dist = sc.nextInt();
			pos[i] = pos[i-1] + dist;
		}
		
		// 再整列
		for(int i = 1; i < N; i++){
			if(pos[i] - pos[i-1] < D){
				pos[i] = pos[i-1] + D;
			}
		}
		
		// 出力
		System.out.print(pos[0]);
		for(int i = 1; i < N; i++){
			System.out.print(" " + pos[i]);
		}
		System.out.println("");
	}
}
0