Run ID | Author | Problem | Lang | Verdict | Time | Memory | Code Length | Submit Time |
---|---|---|---|---|---|---|---|---|
41483 | 老方 | 水下探测器 | C++ | Accepted | 1 MS | 236 KB | 243 | 2024-02-21 09:51:06 |
#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; }