COCI '18 Contest 2 #1 Preokret

View as PDF

Submit solution

Points: 5 (partial)
Time limit: 1.0s
Memory limit: 64M

Problem type

If they continue playing like this, soon the basketball players of the world's best league, the NBA, will put a ball in the basket every second. So there will no longer be any defense, tactics nor basketball. Let's imagine observing one of these future matches between Team A and Team B. We know how many points both Team A and Team B have scored and the exact second when it happened. Within a second, it will not be possible to score more than one point. King James is observing the task input and wants to answer the following two questions:

  1. How many points have been scored during the first half-time, that is in the first half of the game, if we know that the entire game lasts 4 \times 12 minutes?

  2. How many "turnarounds" have happened during the match, i.e. how many times has a team come from a losing situation (has strictly fewer points scored than the other team) to a leading one (has strictly more points scored than the other team)?

Input Specification

The first line contains a positive integer A (1 \le A \le 2879), the number of points Team A has scored. In the following A lines there are positive integers As (1 \le As \le 2880), the seconds in which Team A was scoring points ordered from the smallest to the largest number.

In the (A + 2)^{th} line there is a positive integer B (1 \le B \le 2879), the number of points Team B has scored. In the following B lines there are positive integers Bs (1 \le Bs \le 2880), the seconds in which Team B was scoring points ordered from the smallest to the largest number.

Output Specification

In the first line print an integer value, the answer to the first question from the text of the task.

In the second line print an integer value, the answer to the second question from the text of the task.

Scoring

The correct output of the first line is worth 2 points, and the correct output of the second one is worth 3 points. If you do not know how to solve some part of the task, print anything in the corresponding line.

Sample Input 1

3
10
1400
1500
2
7
2000

Sample Output 1

3
1

Sample Input 2

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

Sample Output 2

10
5

Explanation for Sample Output 2

Results' progress "Team A : Team B"Turnaround (YES/NO)
1:0 (15th second, 1st half-time)NO
1:1 (20th second, 1st half-time)NO
1:2 (25th second, 1st half-time)YES (Team B)
2:2 (30th second, 1st half-time)NO
3:2 (35th second, 1st half-time)YES (Team A)
3:3 (40th second, 1st half-time)NO
3:4 (45th second, 1st half-time)YES (Team B)
3:5 (50th second, 1st half-time)NO
4:5 (55th second, 1st half-time)NO
5:5 (60th second, 1st half-time)NO
6:5 (2065th second, 2nd half-time)YES (Team A)
6:6 (2070th second, 2nd half-time)NO
6:7 (2075th second, 2nd half-time)YES (Team B)

Sample Input 3

11
1402
1412
1428
1430
1441
1444
1453
1483
1485
1489
1490
9
1403
1405
1409
1435
1459
1460
1461
1487
1495

Sample Output 3

8
2

Comments


  • 0
    jeano  commented on Feb. 18, 2023, 9:42 a.m.

    Remember :

    • Both teams cannot claim a turnaround at the same time.
    • A team cannot claim multiple successive turnarounds. If team A claims a turnaround, then, if there is a next turnaround, it must be claimed by team B.
    • A turnaround cannot be claimed if one of the teams has 0 points.

    Also, I am still failing question 2 for the three last tests, how come ? My logic seems reasonable enough.


  • 3
    valegrete  commented on Dec. 30, 2022, 3:02 a.m. edited

    Word to the wise, ignore this verbiage:

    will put a ball in the basket every second


  • 1
    ivan79  commented on June 7, 2022, 12:48 p.m.

    Can someone explain the login behind sample output 3. How come there are only 2 turnarounds when there are clearly 4? I don't get it. Makes no sense.


    • 4
      Tofer_G  commented on June 28, 2022, 12:36 a.m.

      Because on two of those instances the lead doesn't change from from team to the other. It gets tied up, but the team who was leading before the tie scores again.


  • 10
    Spitfire720  commented on Jan. 7, 2022, 2:25 p.m.

    A helpful tip: Halftime is from 0 to 1440, inclusive. If you don't cover this, you won't get full marks, although it will still say you ACed the problem. Since the judge doesn't make it really obvious, I decided to put it here. Hope this helps :)


    • 0
      lifendead  commented on June 14, 2022, 6:39 p.m.

      I was wondering, why I missed some points. Thanks


    • 0
      Mingau  commented on May 15, 2022, 4:04 p.m.

      Thank you! =)