Submission #228935

# Submission time Handle Problem Language Result Execution time Memory
228935 2020-05-03T06:22:49 Z VEGAnn Preokret (COCI18_preokret) C++14
50 / 50
5 ms 384 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 3010;
int ans = 0, vl[N], A, B;

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

    cin >> A;

    for (int i = 0; i < A; i++){
        int x; cin >> x;
        vl[x] = 1;
    }

    cin >> B;

    for (int i = 0; i < B; i++){
        int x; cin >> x;
        vl[x] = -1;
    }

    for (int tim = 1; tim <= 1440; tim++)
        ans += abs(vl[tim]);

    cout << ans << '\n';

    ans = 0;

    int lst = 0, cur = 0;

    for (int tim = 1; tim <= 2880; tim++){
        cur += vl[tim];

        if (cur != 0){
            if (lst != 0){
                if (lst > 0 && cur < 0)
                    ans++;

                if (lst < 0 && cur > 0)
                    ans++;
            }

            lst = cur;
        }
    }

    cout << ans;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct