Files
python/LuoGu/RuMen/P2077.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

36 lines
1.0 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#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;
}