poj3672

来源:互联网 发布:李小龙 泰森 知乎 编辑:程序博客网 时间:2024/05/19 09:50
//poj3672 上山 下山 平地 如何及时返回#include <iostream>using namespace std;int main(){int m, t, u, f, d;cin>>m>>t>>u>>f>>d;char c;int total = 0;int k = 0;for(int i = 0; i < t; i++){cin>>c;if(total <= m){if(c == 'u')total += u + d;else if(c == 'f')total += f * 2;else if(c == 'd')total += d + u;k++;}}cout<<k-1<<endl;return 0;}

0 0
原创粉丝点击