Run ID | Author | Problem | Lang | Verdict | Time | Memory | Code Length | Submit Time |
---|---|---|---|---|---|---|---|---|
41456 | Jeremy | 水下探测器 | C++ | Accepted | 0 MS | 252 KB | 271 | 2024-02-21 09:11:55 |
#include<iostream> #include<cstring> using namespace std; int main() { char a[110]; int n,s; cin>>n>>s>>a; for(int i=0;i<strlen(a);i++){ if(a[i]=='u'){ if(s>0) s--; } else if(a[i]=='d'){ if(s<n) s++; } } cout<<s<<endl; return 0; }