Run ID | Author | Problem | Lang | Verdict | Time | Memory | Code Length | Submit Time |
---|---|---|---|---|---|---|---|---|
42491 | hu | 水下探测器 | C++ | Accepted | 1 MS | 252 KB | 292 | 2024-02-29 16:57:49 |
#include<bits/stdc++.h> using namespace std; int main() { int h, s; string str; cin >> h >> s >> str; for (int i = 0; str[i] != '\0'; i++) { if(str[i] == 'u' && s > 0) { s = s - 1; }else if(str[i] == 'd' && s < h) { s = s + 1; } } cout << s; return 0; }