답안 #671972

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
671972 2022-12-14T13:39:39 Z borisAngelov Election (BOI18_election) C++11
0 / 100
7 ms 340 KB
#include <iostream>

using namespace std;

const int maxn = 500005;

int n;
string s;

void fastIO()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int main()
{
    fastIO();

    cin >> n >> s;
    s = '#' + s;

    int q;
    cin >> q;

    while (q--)
    {
        int l, r;
        cin >> l >> r;

        int c = 0;
        int t = 0;
        int ans1 = 0;
        int ans2 = 0;

        for (int i = l; i <= r; ++i)
        {
            if (s[i] == 'C') c++;
            else
            {
                if (t + 1 <= c) t++;
                else ans1++;
            }
        }

        c = 0;
        t = 0;

        for (int i = r; i >= l; --i)
        {
            if (s[i] == 'C') c++;
            else
            {
                if (t + 1 <= c) t++;
                else ans2++;
            }
        }

        cout << max(ans1, ans2) << "\n";
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -