You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
1.0 KiB

2 years ago
#include <bits/stdc++.h>
using namespace std;
const int N = 100005;//定义一个不可改变的变量
int n, m;
int a[N], r[N], g[N];//每个路口间的距离红灯时间red绿灯时间green
int main() {
//读入输出优化的强迫症
ios::sync_with_stdio(false);
//读入
cin >> n >> m;
//记住有n个路口只有n-1个距离
for (int i = 1; i < n; i++) {
cin >> a[i];
}
//读入红灯时间
for (int i = 1; i <= n; i++) {
cin >> r[i];
}
//读入绿灯时间
for (int i = 1; i <= n; i++) {
cin >> g[i];
}
//对时间进行处理
for (int i = 1; i <= n; i++) {
//如果当前时间不在绿灯范围内就将m加上当前时间与最近的当前路口的绿灯的时间差
if (m % (r[i] + g[i]) > g[i]) {
m += (r[i] + g[i]) - m % (r[i] + g[i]);
}
cout << m << endl;//输出时间
m += a[i];//加上通过第i到i+1个路口间距离的时间
}
return 0;
}