3
30
2015
0

Tyvj 1003 越野跑

#include <cstdio>
#include <iostream>
using namespace std;
long long m,t;
int u,f,d,n;
char s;
int main()
{
	cin>>m>>n>>u>>f>>d;
	u+=d; f*=2; //去加回的距离一起算
	for (int i=1;i<=n;++i) {
		cin>>s;
		if (s=='u' || s=='d') t+=u; //若为坡,直接加
		else t+=f;
		if (t>m) {
			cout<<i-1; //直到超过秒数
			return 0;
		}
	}
	if (t<=m) cout<<n;
	return 0;
}
Category: 题解 | Tags: Tyvj 模拟 | Read Count: 226

登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter

Host by is-Programmer.com | Power by Chito 1.3.3 beta | Theme: Aeros 2.0 by TheBuckmaker.com