跳到正文

题解

晴天 题解

VinstaG173约 1 分钟
原文
文章信息与版本

文章信息

发布
2025年7月17日
收录
2026年7月17日
更新
2026年11月8日
篇幅
约 1 分钟
获赞
10
题目
P15545

版本

  1. v1当前

签到题。

根据题意模拟即可,根据 viv_i 的值判断给路程加上 x,0x,0 或 x−vix-v_i,每天判断路程是否 ≥s\ge s 即可。

Code:

C++
nt n,s,x,v,t;
inline void solve(){
	cin>>n>>s>>x;t=0;
  
	for(int i=1;i<=n;++i){
		cin>>v;
		
		if(v==0)t+=x;
		else if(v>0){
			t-=v;t+=x;
		}
		
		if(t>=s){
			cout<<i<<"\n";
			return;
		}
	}
	
	cout<<"-1\n";
	return;
}