Run ID | Author | Problem | Lang | Verdict | Time | Memory | Code Length | Submit Time |
---|---|---|---|---|---|---|---|---|
15553 | 马德理666 | 水下探测器 | C++ | Accepted | 0 MS | 244 KB | 347 | 2023-04-23 22:29:36 |
#include <bits/stdc++.h> using namespace std; int main(){ int h,s; char a[100]; cin >> h >> s; cin >> a; int depth=s; for(int i=0;i<strlen(a);i++) { if(a[i]=='u') { depth--; if(depth<0){ depth++; } } if(a[i]=='d') { depth++; if(depth>h){ depth--; } } } cout << depth; }