Submission #86968

# Submission time Handle Problem Language Result Execution time Memory
86968 2018-11-29T02:27:29 Z FutymyClone Preokret (COCI18_preokret) C++14
50 / 50
3 ms 552 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 3005;

int n, m;
vector <pair <int, int> > vec;

int main(){
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        int x;
        scanf("%d", &x);
        vec.push_back({x, 1});
    }

    scanf("%d", &m);
    for (int i = 1; i <= m; i++) {
        int x;
        scanf("%d", &x);
        vec.push_back({x, 2});
    }

    sort(vec.begin(), vec.end());
    int ans = 0;
    for (auto i: vec) if (i.first <= 1440) ans++;
    printf("%d\n", ans);

    bool f1 = false, f2 = false;
    int cur1 = 0, cur2 = 0, res = 0;
    for (auto i: vec) {
        if (i.second == 1) {
            if (f2 && cur1 == cur2) res++, f2 = false;
            cur1++;

            if (cur1 > cur2) f1 = true;
        }
        else {
            if (f1 && cur2 == cur1) res++, f1 = false;
            cur2++;

            if (cur2 > cur1) f2 = true;
        }
    }
    printf("%d", res);
    return 0;
}

Compilation message

preokret.cpp: In function 'int main()':
preokret.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
preokret.cpp:14:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &x);
         ~~~~~^~~~~~~~~~
preokret.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &m);
     ~~~~~^~~~~~~~~~
preokret.cpp:21:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &x);
         ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 3 ms 440 KB Output is correct
4 Correct 2 ms 440 KB Output is correct
5 Correct 2 ms 488 KB Output is correct
6 Correct 3 ms 500 KB Output is correct
7 Correct 3 ms 520 KB Output is correct
8 Correct 3 ms 528 KB Output is correct
9 Correct 2 ms 528 KB Output is correct
10 Correct 2 ms 552 KB Output is correct