結果

問題 No.1090 ソーシャルディスタンス / Social Distance
ユーザー chacoder1
提出日時 2021-07-03 22:40:48
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 74 ms / 2,000 ms
コード長 510 bytes
コンパイル時間 1,847 ms
コンパイル使用メモリ 195,608 KB
最終ジャッジ日時 2025-01-22 17:21:04
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

signed main(){
  int n,d;
  cin>>n>>d;
  vector<int>dist(n-1);
  vector<int>pos(n,0);
  rep(i,n-1) cin>>dist[i];
  rep(i,n-1) {
    pos[i+1]=pos[i]+dist[i];
    //cout<<i+1<<" "<<pos[i+1]<<endl;
  }
  cout<<0;
  int temp=0;
  rep(i,n-1){
    cout<<" ";
    if(temp+d<=pos[i+1]){
      temp=pos[i+1];
      cout<<pos[i+1];
      continue;
    }
    else{
      temp+=d;
      cout<<temp;
    }
  }
  cout<<endl;
  return 0;
}
0