Submission #146083

# Submission time Handle Problem Language Result Execution time Memory
146083 2019-08-22T01:57:40 Z youssan_william Preokret (COCI18_preokret) C++14
50 / 50
4 ms 508 KB
#include <bits/stdc++.h>

using namespace std;
typedef int ll;
int main()
{
    ll a , b;
    cin >> a;
    ll arr[a];
    ll mid=1440;
    map<ll,char>mp;
    vector<ll>goals;
    for(int i = 0 ; i < a ;i++)
    {
        cin >> arr[i];
        goals.push_back(arr[i]);
        mp[arr[i]]='a';
    }
    cin >> b;
    ll arr2[b];
    for(int i = 0 ; i < b ;i++)
    {
        cin >> arr2[i];
        goals.push_back(arr2[i]);
        mp[arr2[i]]='b';
    }
    sort(goals.begin(),goals.end());
    ll ans=0 , teamA=0 , teamB=0 , turnarounds=0, winA=0,winB=0 , newloser;
    for(int i = 0 ; i < goals.size() ;i++)
    {
        if(teamA>teamB)
        {
            winA=1;
            winB=0;
        }
        if(teamB>teamA)
        {
            winB=1;
            winA=0;
        }
        if(mp[goals[i]]=='a')
        {
            teamA++;
            if(teamA>teamB&&winB==1)
            {
                winA=1;
                winB=0;
                turnarounds++;
            }
        }
        else
        {
            teamB++;
            if(teamB>teamA&&winA==1)
            {
                winA=0;
                winB=1;
                turnarounds++;
            }
        }
        if(goals[i]<=mid)
            ans++;

    }
    //turnarounds=43678568;
    cout << ans << "\n" << turnarounds ;
    return 0;
}

Compilation message

preokret.cpp: In function 'int main()':
preokret.cpp:29:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0 ; i < goals.size() ;i++)
                     ~~^~~~~~~~~~~~~~
preokret.cpp:28:67: warning: unused variable 'newloser' [-Wunused-variable]
     ll ans=0 , teamA=0 , teamB=0 , turnarounds=0, winA=0,winB=0 , newloser;
                                                                   ^~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 128 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 3 ms 508 KB Output is correct
8 Correct 3 ms 504 KB Output is correct
9 Correct 4 ms 504 KB Output is correct
10 Correct 2 ms 376 KB Output is correct