Run ID | Author | Problem | Lang | Verdict | Time | Memory | Code Length | Submit Time |
---|---|---|---|---|---|---|---|---|
47377 | 惠子铭 | 水下探测器 | C++ | Accepted | 0 MS | 244 KB | 249 | 2024-05-17 15:33:45 |
#include<bits/stdc++.h> 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; return 0; }