Submission #384713

# Submission time Handle Problem Language Result Execution time Memory
384713 2021-04-02T06:00:17 Z AdiZer0 Preokret (COCI18_preokret) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

#define pb push_back
#define whole(x) x.begin(), x.end()
#define sz(x) (int)x.size()

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = (int)1e5 + 7;
const int INF = (int)1e9 + 7;
const ll linf = (ll)1e18 + 1;
 
int n, a[N];
int m, b[N];

int main() {
    scanf ("%d", &n);
    for (int i = 1; i <= n; ++i) scanf ("%d", a + i);
    scanf ("%d", &m);
    for (int i = 1; i <= m; ++i) scanf ("%d", b + i);
    int who = -1, p1 = 1;
    int half = 0, turn = 0;
    int numA = 0, numB = 0;
    b[m + 1] = INF:
    for (int i = 1; i <= n;) {
        if (a[i] < b[p1])  {
            if (a[i] <= 1440) ++half;
            numA++;
            ++i;
        } else { 
            if (b[p1] <= 1440) ++half;
            numB++;
            ++p1;
        }
        if (who == -1) {
            if (numA > numB) who = 0;
            else who = 1;
        } else { 
            if (who)  {
                if (numA > numB) who = 0, ++turn;
            } else { 
                if (numA < numB) who = 1, ++turn;
            }
        }
    }
    while (p1 <= m) { 
        ++numB;
        if (b[p1] <= 1440) ++half;
        if (who == -1) {
            if (numA > numB) who = 0;
            else who = 1;
        } else { 
            if (who)  {
                if (numA > numB) who = 0, ++turn;
            } else { 
                if (numA < numB) who = 1, ++turn;
            }
        }
        ++p1;
    }
    printf ("%d\n%d\n", half, turn);
    return 0;
}

/*
6
15 30 35 55 60 2065
7
20 25 40 45 50 2070 2075
*/

Compilation message

preokret.cpp: In function 'int main()':
preokret.cpp:27:19: error: expected ';' before ':' token
   27 |     b[m + 1] = INF:
      |                   ^
      |                   ;
preokret.cpp:28:21: error: 'i' was not declared in this scope
   28 |     for (int i = 1; i <= n;) {
      |                     ^
preokret.cpp:28:28: error: expected primary-expression before ')' token
   28 |     for (int i = 1; i <= n;) {
      |                            ^
preokret.cpp:20:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   20 |     scanf ("%d", &n);
      |     ~~~~~~^~~~~~~~~~
preokret.cpp:21:40: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   21 |     for (int i = 1; i <= n; ++i) scanf ("%d", a + i);
      |                                  ~~~~~~^~~~~~~~~~~~~
preokret.cpp:22:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   22 |     scanf ("%d", &m);
      |     ~~~~~~^~~~~~~~~~
preokret.cpp:23:40: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   23 |     for (int i = 1; i <= m; ++i) scanf ("%d", b + i);
      |                                  ~~~~~~^~~~~~~~~~~~~