TLE '16 Contest 1 P1 - Buying Paper

View as PDF

Submit solution


Points: 3 (partial)
Time limit: 2.0s
Memory limit: 128M

Authors:
Problem type

Someone is going through his final year of high school. For privacy reasons, we will refer to him as "the CS nerd." He is thinking about prom and one specific girl. For privacy reasons, we will refer to her as "the girl."

The CS nerd wants to get the girl's attention. Upon asking his equally nerdy CS friends, he was suggested to air-drop thousands of papers littered with equations of cardioid graphs over the girl's house (the girl might or might not know what these equations even mean). However, the CS nerd needs many dimes/quarters to buy copious amounts of paper in order to accomplish this task. He isn't sure whether quarters (25 cents) are more efficient to bring than dimes (10 cents).

To help solve this question, his friends made very precise measurements of dimes and quarters. Dimes were measured D times (1 \le D \le 1\,000) and quarters were measured Q times (1 \le Q \le 1\,000). It is guaranteed that each measurement is an integer between 1 and 10^6.

After the friends made the measurements, they are still not sure about which coin is better. They want their answer to be 100% certain.

A coin's value is defined as the number of cents divided by the mass. A 5 cent coin with a mass of 4 mg would have a value of 1.25.

Dimes are better if the heaviest dimes are strictly more valuable than the lightest quarters.

For example, if the heaviest dime weighs 1000 mg and the lightest quarter weighs 2501 mg, then dimes are better. If instead, the lightest quarter weighs 2500 mg, the answer cannot be 100% certain because neither coin would be better.

Similarly, quarters are better if the heaviest quarters are strictly more valuable than the lightest dimes.

Please help determine whether quarters or dimes are better!

Input Specification

The first line contains the integer D.

The second line contains D space separated integers, which are the weights of the measured dimes.

The third line contains the integer Q.

The fourth line contains Q space separated integers, which are the weights of the measured quarters.

Output Specification

If dimes are better, output Dimes are better.

If quarters are better, output Quarters are better.

Otherwise, output Neither coin is better.

Sample Input 1

5
1112 1101 1079 1104 1113
5
2605 2643 2618 2648 2656

Sample Output 1

Quarters are better

Sample Input 2

1
1000
1
2500

Sample Output 2

Neither coin is better

Comments


  • 1
    Ken_Shi  commented on Dec. 24, 2016, 2:46 p.m.

    Why I cannot pass case 7#????? Is there anybody who knows the trick??


  • 0
    paydayzcool  commented on Sept. 22, 2016, 8:23 a.m. edited

    if the heaviest dime weighs 1000 mg and the lightest quarter weighs 2501 mg, then dimes are better.

    Wait, this problem is telling me that dimes are better if the heaviest dime is lighter than the lightest quarter?


    • 0
      nathanl3  commented on Sept. 22, 2016, 11:07 a.m.
      • A coin's value is defined as number of cents divided by the mass. A 5 cent coin with a mass of 4 mg would have a value of 1.25.
        • Dimes are better if the heaviest dimes are strictly more valuable than the lightest quarters.

  • 0
    bobhob314  commented on Sept. 22, 2016, 12:04 a.m. edited

    2656/25 is 106.24 < 1079/10 = 107.9

    edit nvm


  • 0
    bobhob314  commented on Sept. 21, 2016, 11:50 p.m.

    gl cs nerd


  • 0
    nathanl3  commented on Sept. 21, 2016, 6:33 p.m.

    The problem statement has been updated to clear up some apparent confusion.


    • 9
      bobhob314  commented on Sept. 22, 2016, 12:00 a.m.

      dw it's still confusing