/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 1ms 488.0 KiB
#3 Accepted 1ms 532.0 KiB
#4 Accepted 2ms 484.0 KiB
#5 Accepted 1ms 348.0 KiB
#6 Accepted 1ms 488.0 KiB
#7 Accepted 1ms 532.0 KiB
#8 Accepted 1ms 520.0 KiB
#9 Accepted 2ms 508.0 KiB
#10 Accepted 2ms 532.0 KiB

Code

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int m,n; cin>>m>>n;
    int mahfuj[7][m],nayon[7][n];
    for(int i=0;i<7;i++)
    {
        for(int j=0;j<m;j++) cin>>mahfuj[i][j];
    }
    for(int i=0;i<7;i++)
    {
        for(int j=0;j<n;j++) cin>>nayon[i][j];
    }

    int mxStreakM=0,mxStreakN=0,mxSubM=0,mxSubN=0;
    int streak=0,submissions=0;
    for(int i=0;i<m;i++)
    {
        for(int j=0;j<7;j++)
        {
            if(mahfuj[j][i]==0) 
            {
                if(streak==mxStreakM)
                {
                    mxSubM=max(mxSubM,submissions);
                }
                else if(streak>mxStreakM)
                {
                    mxStreakM=streak;
                    mxSubM=submissions;
                }
                streak=0;
                submissions=0;
            }
            else
            {
                streak++;
                submissions += mahfuj[j][i];
            }
        }
    }
    
    if(streak==mxStreakM)
    {
        mxSubM=max(mxSubM,submissions);
    }
    else if(streak>mxStreakM)
    {
        mxStreakM=streak;
        mxSubM=submissions;
    }

    streak = 0; submissions=0;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<7;j++)
        {
            if(nayon[j][i]==0) 
            {
                if(streak==mxStreakN)
                {
                    mxSubN=max(mxSubN,submissions);
                }
                else if(streak>mxStreakN)
                {
                    mxStreakN=streak;
                    mxSubN=submissions;
                }
                streak=0;
                submissions=0;
            }
            else
            {
                streak++;
                submissions += nayon[j][i];
            }
        }
    }

    if(streak==mxStreakN)
    {
        mxSubN=max(mxSubN,submissions);
    }
    else if(streak>mxStreakN)
    {
        mxStreakN=streak;
        mxSubN=submissions;
    }
    
    
    if(mxStreakM!=mxStreakN)
    {
        if(mxStreakM>mxStreakN) cout<<"Mahfuz is the boss";
        else cout<<"Nayon is the boss";
    }
    else
    {
        if(mxSubM>mxSubN) cout<<"Mahfuz is the boss";
        else if(mxSubN>mxSubM) cout<<"Nayon is the boss";
        else cout<<"No one is the boss";
    }
}

Information

Submit By
Type
Submission
Problem
P1017 Solution streak
Language
C++20 (G++ 13.2.0)
Submit At
2023-12-10 08:09:37
Judged At
2024-11-11 03:49:10
Judged By
Score
100
Total Time
2ms
Peak Memory
532.0 KiB