Run ID | Author | Problem | Lang | Verdict | Time | Memory | Code Length | Submit Time |
---|---|---|---|---|---|---|---|---|
43351 | Xiyou | 水下探测器 | C++ | Accepted | 0 MS | 252 KB | 263 | 2024-03-11 21:36:46 |
#include<bits/stdc++.h> using namespace std; int main(){ int n,m; cin>>n>>m; char ud[110]; cin>>ud; int s=m; for(int i=0;i<strlen(ud);i++){ if(ud[i]=='u'&&s>0){ s-=1; }else if(ud[i]=='d'&&s<n){ s+=1; } } cout<<s; return 0; }