提交时间:2024-02-21 09:05:43

运行 ID: 41450

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