답안 #107077

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
107077 2019-04-21T20:20:06 Z aryaman Preokret (COCI18_preokret) C++14
50 / 50
3 ms 384 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;

typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ld> vd;
typedef vector<ll> vl;
 
#define mp make_pair
#define pb push_back
#define f first
#define s second

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int a, b, y;
    vii x;
    cin >> a;
    for (int i = 0; i < a; i++) {
        cin >> y;
        x.pb({y, 0});
    }
    cin >> b;
    for (int i = 0; i < b; i++) {
        cin >> y;
        x.pb({y, 1});
    }
    sort(x.begin(), x.end());
    
    int ans1 = -1, ans2 = 0;
    int as = 0, bs = 0;
    bool winner = false;
    for (int i = 0; i < a + b; i++) {
        if (x[i].f > 1440 and ans1 == -1) ans1 = as + bs;
        if (i == 0) {
            if (x[i].s == 1) {
                as++;
                winner = true;
            }
            else {
                bs++;
                winner = false;
            }
        }
        else {
            if (x[i].s == 1) as++;
            else bs++;
            if (bs > as and winner) {
                winner = false;
                ans2++;
            }
            if (as > bs and !winner) {
                winner = true;
                ans2++;
            }
        }
    }
    if (ans1 == -1) ans1 = as + bs;

    cout << ans1 << endl;
    cout << ans2 << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct