제출 #1337015

#제출 시각아이디문제언어결과실행 시간메모리
1337015bilgetux38Grid Coloring (JOI25_ho_t1)C++20
0 / 100
28 ms3396 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#pragma GCC optimize ("Ofast")

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n;
    cin>>n;
    vector<int> a(n+2), b(n+2);
    for (int i = 0; i < n; ++i)
    {
        cin>>a[i+1];
    }
    for (int i = 0; i < n; ++i)
    {
        cin>>b[i+1];
    }
    int mxa = 0, mai = 0;
    int mxb = 0, mbi = 0;
    int sya = 0, syb = 0;
    for (int i = 2; i <= n; ++i)
    {
        if (mxa == a[i])
        {
            ++sya;
        }
        
        if (mxa < a[i])
        {
            mxa = a[i];
            mai = i;
            sya = 1;
        }
        
    }
    for (int i = 2; i <= n; ++i)
    {
        if (mxb == b[i])
        {
            syb++;
        }
        
        if (mxb < b[i])
        {
            mxb = b[i];
            mbi = i;
            syb = 1;
        }
        
    }
    if (a[1] > mxa & a[1] > mxb)
    {
        cout<<a[1]<<' '<<1<<endl;
    }    
    else if (mxa == mxb)
    {
        int ynt = ((n - mai + 1) * (n - 1)) + ((n - mbi + 1) * (n - 1));
        ynt -= (n - mai + 1) * (n - mbi + 1);
        if (a[1] == mxa)
            ++ynt;
        ynt += sya +syb ;
        cout<<mxa<<' '<<ynt<<endl;
    }
    else if (mxa > mxb)
    {
        int ynt = ((n - mai + 1) * (n - 1));
        if (a[1] == mxa)
            ++ynt;
        ynt += sya ;
        cout<<mxa<<' '<<ynt<<endl;
    }
    else
    {
        int ynt = ((n - mbi + 1) * (n - 1));
        if (b[1] == mxb)
            ++ynt;
        ynt += syb ;
        cout<<mxb<<' '<<ynt<<endl;
    }

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...