提交时间:2024-02-21 09:51:06

运行 ID: 41483

#include<bits/stdc++.h> using namespace std; int main(){ int h,s; cin>>h>>s; char code[105]; cin>>code; for(int i=0;i<strlen(code);i++){ if(code[i]=='u'&&s>0)s-=1; else if(code[i]=='d'&&s<h)s+=1; } cout<<s; return 0; }