Run ID | Author | Problem | Lang | Verdict | Time | Memory | Code Length | Submit Time |
---|---|---|---|---|---|---|---|---|
41452 | Andrew宥杨 | 水下探测器 | C++ | Accepted | 0 MS | 248 KB | 249 | 2024-02-21 09:06:34 |
#include<bits/stdc++.h> using namespace std; int main(){ int h,s; cin>>h>>s; string a; cin>>a; for(int i=0;i<a.size();i++){ if(a[i]=='u' && s>0){ s--; } else if(a[i]=='d' && s<h){ s++; } } cout<<s; return 0; }