Submission #339594

# Submission time Handle Problem Language Result Execution time Memory
339594 2020-12-25T16:54:33 Z ammar2000 Preokret (COCI18_preokret) C++17
50 / 50
2 ms 620 KB
#include <bits/stdc++.h>
using namespace std;
int a,b,fh,cb;
char cw='s';
map <int ,char> c;
int main()
{
    cin>>a;
    while (a--)
    {
        int y;
        cin>>y;
        if (y<=1440)
            fh++;
        c[y]='a';
    }
    cin>>b;
    while (b--)
    {
        int y;
        cin>>y;
        if (y<=1440)
            fh++;
        c[y]='b';
    }
    a=b=0;
    for (int i=1;i<=2888;i++)
    {
        if (c[i]=='a')
            a++;
        else if (c[i]=='b')
            b++;
        if (cw=='s')
        {
            if (a>b)
                cw='a';
            else if (a<b)
                cw='b';
        }
        else
        {
            if (a>b)
            {
                if (cw=='b')
                    cb++;
                cw='a';
            }
            else if (b>a)
            {
                if (cw=='a')
                    cb++;
                cw='b';
            }
        }
    }
    cout <<fh<<" "<<cb;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 492 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 1 ms 492 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
5 Correct 1 ms 492 KB Output is correct
6 Correct 2 ms 620 KB Output is correct
7 Correct 2 ms 492 KB Output is correct
8 Correct 2 ms 492 KB Output is correct
9 Correct 2 ms 492 KB Output is correct
10 Correct 1 ms 492 KB Output is correct