Codeforces Round #625 (Div. 2, based on Technocup 2020 Final Round) A. Contest for Robots(思维题)

Polycarp is preparing the first programming contest for robots. There are nn problems in it, and a lot of robots are going to participate in it. Each robot solving the problem ii gets pipi points, and the score of each robot in the competition is calculated as the sum of pipi over all problems ii solved by it. For each problem, pipi is an integer not less than 11 .

Two corporations specializing in problem-solving robot manufacturing, "Robo-Coder Inc." and "BionicSolver Industries", are going to register two robots (one for each corporation) for participation as well. Polycarp knows the advantages and flaws of robots produced by these companies, so, for each problem, he knows precisely whether each robot will solve it during the competition. Knowing this, he can try predicting the results — or manipulating them.

For some reason (which absolutely cannot involve bribing), Polycarp wants the "Robo-Coder Inc." robot to outperform the "BionicSolver Industries" robot in the competition. Polycarp wants to set the values of pipi in such a way that the "Robo-Coder Inc." robot gets strictly more points than the "BionicSolver Industries" robot. However, if the values of pipi will be large, it may look very suspicious — so Polycarp wants to minimize the maximum value of pipi over all problems. Can you help Polycarp to determine the minimum possible upper bound on the number of points given for solving the problems?

Input

The first line contains one integer nn (1n1001≤n≤100 ) — the number of problems.

The second line contains nn integers r1r1 , r2r2 , ..., rnrn (0ri10≤ri≤1 ). ri=1ri=1 means that the "Robo-Coder Inc." robot will solve the ii -th problem, ri=0ri=0 means that it won't solve the ii -th problem.

The third line contains nn integers b1b1 , b2b2 , ..., bnbn (0bi10≤bi≤1 ). bi=1bi=1 means that the "BionicSolver Industries" robot will solve the ii -th problem, bi=0bi=0 means that it won't solve the ii -th problem.

Output

If "Robo-Coder Inc." robot cannot outperform the "BionicSolver Industries" robot by any means, print one integer 1−1 .

Otherwise, print the minimum possible value of maxi=1npimaxi=1npi , if all values of pipi are set in such a way that the "Robo-Coder Inc." robot gets strictly more points than the "BionicSolver Industries" robot.

Examples
Input
 
5
1 1 1 0 0
0 1 1 1 1
Output
 
3
Input
 
3
0 0 0
0 0 0
Output
 
-1
Input
 
4
1 1 1 1
1 1 1 1
Output
 
-1
Input
 
9
1 0 0 0 0 0 0 0 1
0 1 1 0 1 1 1 1 0
Output
 
4 
thinking that, I spent a few if-else judge, a bit long-winded ...
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,x=0,y=0;
    int a[105],b[105];
    cin>>n;
    int i;
    for(i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=1;i<=n;i++)
    {
        scanf("%d",&B [I]); 
    } for (I = . 1 ; I <= n-; I ++) // will not do or do not do not affect the statistical 
    {
         IF (A [I] && (B [I]!) ) X ++; // X is a number of problems will do 
        the else  IF ((a [I]!) && B [I]) Y ++ ; 
    } 
    IF (X == Y) // is equal to 
    {
         IF (X) COUT << 2 ; // not a zero, then there is a winner take 2 can ensure 
        the else COUT << - 1 ; // can not be feasible if the 0 
    }
     the else  IF (X> Y) // X> Y 1 taken on the line the whole 
    { 
        COUT << 1; 
    } 
    The else // X <Y 
    {
         IF (X == . 1 ) 
        { 
            COUT << + Y . 1 ; // a problem that made out of y + 1 can directly take out a guarantee winning 
        }
         the else  IF (X = = 0 ) COUT << - 1 ; // impossible 
        the else 
        { 
            COUT << Y / x + 1 ; // can be understood as a number x Y can top, plus one can guarantee Wynn (x questions asked to make note may be small, so to Y / X) 
        } 
    } 
    return  0 ; 
}

 

Guess you like

Origin www.cnblogs.com/lipoicyclic/p/12399226.html