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.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
# 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 ;
}