B - Ticket Counter
https://atcoder.jp/contests/abc358/tasks/abc358_b
思路
第i个完成的时刻,done[i] 跟第i-1完成时间done[i-1]有关系,
第i个的开始时刻t[i] 大于 done[i-1], done[i] = t[i]+a
第i个的开始时刻t[i] 不大于 done[i-1], done[i] = done[i-1]+a
Code
https://atcoder.jp/contests/abc358/submissions/54590343
int n, a; int t[105], done[105]; int main() { cin >> n >> a; for(int i=0; i<n; i++){ cin >> t[i]; if (i==0){ done[0] = t[i]+a; } else { if (t[i] >= done[i-1]){ done[i] = t[i] + a; } else{ done[i] = done[i-1] + a; } } } for(int i=0; i<n; i++){ cout << done[i] << endl; } return 0; }
标签:int,Counter,done,Ticket,contests,abc358 From: https://www.cnblogs.com/lightsong/p/18251440