This page is still under construction.

Parts of this page are still being built. What you see may change.

Fraud

Time limit1sMemory limit1024 MB

Summary
Decide whether positive integers X and Y exist so that the weighted score Ai*X + Bi*Y strictly decreases along the given contestant order.
Level

Medium7 of 10

Topics
Geometry, Sorting, Greedy, Math
Solved
No attempts yet

Problem

You have been put in charge of the 24th National Olympiad in Informatics!

This year, the competition consisted of N contestants and 2 rounds. The ith contestant scored Ai points in the first round and Bi points in the second round.

Furthermore, the rounds have associated positive integer weightages X and Y respectively. The ith contestant’s final score Si is given by Si = Ai × X + Bi × Y.

As the chairman, you have been given the freedom to select the values of X and Y as you wish.

Alas, Squeaky the Mouse has bribed you into committing fraud. To be exact, he has promised to reward you handsomely if you select some X and Y such that Si > Sj for all 1 ≤ i < j ≤ N.

But is it even possible to do so?

Input

Your program must read from standard input.

The first line contains a single integer N, the number of contestants.

The second line contains N space-separated integers, A1, . . . , AN.

The third line contains N space-separated integers, B1, . . . , BN.

Output

Your program must print to standard output.

Output YES if it is possible to commit fraud and NO otherwise.

Constraints

  • 2 ≤ N ≤ 3 × 105
  • 0 ≤ Ai, Bi ≤ 106

Examples3

  1. Example 1

    Input
    2
    1 2
    2 1
    
    Expected output
    YES
    
  2. Example 2

    Input
    3
    2 4 3
    4 2 3
    
    Expected output
    NO
    
  3. Example 3

    Input
    2
    5 1
    0 0
    
    Expected output
    YES