Submission #70599224


Source Code Expand

#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
const int maxn = 3e5+5;
int ca[maxn],cb[maxn];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n,a,b;
    cin>>n>>a>>b;
    string s;
    cin>>s;
    s=' '+s;
    for (int i=1;i<=n;i++)
    {
        ca[i]=ca[i-1];
        cb[i]=cb[i-1];
        if (s[i]=='a')
            ca[i]++;
        else
            cb[i]++;
    }
    long long ans=0;
    for (int i=0;i<n;i++)
    {
        int l=lower_bound(ca,ca+n+1,a+ca[i])-ca;
        int r=lower_bound(cb,cb+n+1,b+cb[i])-cb;
        ans+=max(0,r-l);
    }
    print("{}",ans);
}

Submission Info

Submission Time
Task C - Truck Driver
User Alliy666
Language C++23 (GCC 15.2.0)
Score 300
Code Size 737 Byte
Status AC
Exec Time 24 ms
Memory 9092 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 2
AC × 25
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
All hand.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, sample_01.txt, sample_02.txt
Case Name Status Exec Time Memory
hand.txt AC 10 ms 6436 KiB
random_01.txt AC 16 ms 8988 KiB
random_02.txt AC 15 ms 9016 KiB
random_03.txt AC 16 ms 9092 KiB
random_04.txt AC 15 ms 8952 KiB
random_05.txt AC 19 ms 8940 KiB
random_06.txt AC 18 ms 8884 KiB
random_07.txt AC 18 ms 9008 KiB
random_08.txt AC 19 ms 8960 KiB
random_09.txt AC 18 ms 8984 KiB
random_10.txt AC 19 ms 8940 KiB
random_11.txt AC 19 ms 9048 KiB
random_12.txt AC 18 ms 9044 KiB
random_13.txt AC 21 ms 8884 KiB
random_14.txt AC 23 ms 8960 KiB
random_15.txt AC 21 ms 9084 KiB
random_16.txt AC 21 ms 8940 KiB
random_17.txt AC 24 ms 9020 KiB
random_18.txt AC 24 ms 9056 KiB
random_19.txt AC 11 ms 9016 KiB
random_20.txt AC 18 ms 9044 KiB
random_21.txt AC 20 ms 8948 KiB
random_22.txt AC 19 ms 9016 KiB
sample_01.txt AC 2 ms 6540 KiB
sample_02.txt AC 2 ms 6340 KiB