Rainy Season

Problem Link

Solution by Mr.Olimpia — 100 pts

Code / Notes

#include <bits/stdc++.h>
using namespace std;

// https://ide.usaco.guide/Ov5Bu8j7yJ_6itiOaT2

// P[3] = 5 -> o pai do 3 é o 5
// P[3] = -1 -> 3 não tem pai

int main() {
    string S;
    cin >> S;
    int ans =0;
    int ans1=0;
    for (int i=0; i< S.size(); i++){
        if(S[i]=='R'){
            ans1++;
        }
        if(S[i]=='S'){
            ans= max(ans1, ans);
            ans1=0;
        }
    }
    ans=max(ans,ans1);
    cout << ans;
}

Last updated 1 month, 3 weeks ago


« Back to problem