Submission #692547

# Submission time Handle Problem Language Result Execution time Memory
692547 2023-02-01T22:11:55 Z delrey Preokret (COCI19_preokret) C++14
50 / 50
1 ms 340 KB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n, a;
    cin>>n;
    int goalsCity = 0, goalsOpp = 0, ties = 1, streak = 0, prev = 0, lead = 0, streakMax = 0;
    for(int i = 0; i < n; i++)
    {
        cin>>a;
        if(a == prev)
            streak++;
        else
        {
            streak = 1;
            if(goalsCity > goalsOpp)
                lead = 1;
            else if(goalsCity < goalsOpp)
                lead = 2;
            else
                lead = 0;
        }
        if(a == 1)
            goalsCity++;
        else
            goalsOpp++;
        if(goalsCity > goalsOpp && lead == 2)
            streakMax = max(streak, streakMax);
        if(goalsCity < goalsOpp && lead == 1)
            streakMax = max(streak, streakMax);
        if(goalsCity == goalsOpp)
            ties++;
        prev = a;
    }
    cout<<goalsCity<<" "<<goalsOpp<<endl;
    cout<<ties<<endl;
    cout<<streakMax<<endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 0 ms 300 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct