Run ID:61974

提交时间:2023-12-16 16:32:40

# include<iostream> # include<cstring> using namespace std; char y[105]; int h,s; int main(){ cin>>h>>s; cin>>y; for(int i=0;i<strlen(y);i++){ if(y[i]=='u' and s!=0)s--; if(y[i]=='d' and s!=h)s++; } cout<<s; return 0; }