100 Accepted

foo.cc: In function 'int main()':
foo.cc:9:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
     for(int i=0;i<c.length();i++)
                 ~^~~~~~~~~~~
# 状态 分数 耗时 内存占用
#1 Accepted 10 1ms 7.6 MiB
#2 Accepted 10 1ms 7.5 MiB
#3 Accepted 10 1ms 7.5 MiB
#4 Accepted 10 1ms 7.7 MiB
#5 Accepted 10 1ms 7.6 MiB
#6 Accepted 10 0ms 7.4 MiB
#7 Accepted 10 1ms 7.6 MiB
#8 Accepted 10 0ms 7.6 MiB
#9 Accepted 10 1ms 7.5 MiB
#10 Accepted 10 1ms 7.6 MiB

代码

#include <bits/stdc++.h> 
using namespace std;
int a,b;
string c;
int main()
{
    cin>>a>>b;
    cin>>c;
    for(int i=0;i<c.length();i++)
    {
        if(c[i]=='u' && b>0)
        {
            b=b-1;
        }
        if(c[i]=='d' && b<a)
        {
            b++;
        }
    }
    cout<<b;
    return 0;
}

信息

递交者
题目
LQ1071  水下探测器
比赛
蓝桥杯省赛历年真题
语言
C++ 17 (O2)
递交时间
6 个月前
评测时间
6 个月前
分数
100
总耗时
8ms
峰值内存
7.7 MiB