結果

問題 No.1090 ソーシャルディスタンス / Social Distance
ユーザー bluemegane
提出日時 2020-06-24 13:26:13
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 82 ms / 2,000 ms
コード長 671 bytes
コンパイル時間 1,117 ms
コンパイル使用メモリ 111,040 KB
実行使用メモリ 41,604 KB
最終ジャッジ日時 2024-07-03 20:07:10
合計ジャッジ時間 3,761 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 23
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using static System.Math;
using System;

public class Hello
{
    static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var d = int.Parse(line[1]);
         line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        getAns(n, d, a);
    }
    static void getAns (int n,int d, int[] a)
    {
        var res = new int[n];
        res[0] = 0;
       var now = 0;
        for (int i = 0; i < n-1; i++)
        {
            now += a[i];
            res[i + 1]  = Max(now, res[i] + d);
        }
        Console.WriteLine(string.Join(" ",res));
    }
}
0