結果

問題 No.1090 ソーシャルディスタンス / Social Distance
ユーザー arito_asu
提出日時 2020-07-01 17:08:31
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 36 ms / 2,000 ms
コード長 562 bytes
コンパイル時間 577 ms
コンパイル使用メモリ 64,036 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-14 02:25:50
合計ジャッジ時間 2,379 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;

int main() {
    
    int n,d; cin >> n >> d;
    
    int a[n-1]; for(int i=0;i<n-1;i++) { cin >> a[i]; }
    
    int ls[n]; ls[0] = 0;
    for(int i=0;i<n-1;i++) { ls[i+1] = ls[i] + a[i]; }
    
    for (int i=0;i<n-1;i++) {
        int dif = ls[i+1] - ls[i];
        if (dif < d) {
            ls[i+1] = ls[i+1] + (d-dif);
        }
    }
    
    for (int i=0;i<n;i++) {
        if (i==0) {
            cout << ls[i];
        } else {
            cout << ' ' << ls[i];
        }
        
    }
    
    return 0;

}
0