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

A. Contest for Robots
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
Polycarp is preparing the first programming contest for robots. There are n problems in it, and a lot of robots are going to participate in it. Each robot solving the problem i gets pi points, and the score of each robot in the competition is calculated as the sum of pi over all problems i solved by it. For each problem, pi is an integer not less than 1.

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 pi in such a way that the “Robo-Coder Inc.” robot gets strictly more points than the “BionicSolver Industries” robot. However, if the values of pi will be large, it may look very suspicious — so Polycarp wants to minimize the maximum value of pi 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 n (1≤n≤100) — the number of problems.

The second line contains n integers r1, r2, …, rn (0≤ri≤1). ri=1 means that the “Robo-Coder Inc.” robot will solve the i-th problem, ri=0 means that it won’t solve the i-th problem.

The third line contains n integers b1, b2, …, bn (0≤bi≤1). bi=1 means that the “BionicSolver Industries” robot will solve the i-th problem, bi=0 means that it won’t solve the i-th problem.

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

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

Examples
inputCopy
5
1 1 1 0 0
0 1 1 1 1
outputCopy
3
inputCopy
3
0 0 0
0 0 0
outputCopy
-1
inputCopy
4
1 1 1 1
1 1 1 1
outputCopy
-1
inputCopy
9
1 0 0 0 0 0 0 0 1
0 1 1 0 1 1 1 1 0
outputCopy
4
Note
In the first example, one of the valid score assignments is p=[3,1,3,1,1]. Then the “Robo-Coder” gets 7 points, the “BionicSolver” — 6 points.

In the second example, both robots get 0 points, and the score distribution does not matter.

In the third example, both robots solve all problems, so their points are equal.

题意:就是说给了两个长度为n的序列 值只有0和1 对于1表示会
对于0表示不会 现在让你给每个位置给分数 分数要求≥1的整数 想让第一个人的总得分>第二个人 问给的分数最大值是多少 要求这个值尽可能小

思路:对于两个序列 同一位置一样 那就不管他了
对于不一样的 我们去看第一个序列为1 第二个为0的个数w有多少
同理去看第二个序列为1 第一个为0的个数e有多少
要大于第二个 那么我们把只有第二个人会的分数都给一分 也就是得分就是第二个会的第一个不会的个数 要大于他 就总分+1 然后去均分给第一个的即可

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define me(a,x) memset(a,x,sizeof a)
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define all(x) (x).begin(), (x).end()
#define pb(a) push_back(a)
#define paii pair<int,int>
#define pali pair<ll,int>
#define pail pair<int,ll>
#define pall pair<ll,ll>
#define fi first
#define se second
int main()
{


    vector<int> a,b;
    int n;cin>>n;
    a.resize(n+1),b.resize(n+1);
    repd(i,1,n) cin>>a[i];
    repd(i,1,n) cin>>b[i];
    int q=0,w=0,e=0;
    for(int i=1;i<=n;i++){
        if(a[i]==b[i]) q++;
        else if(a[i]>b[i]) w++;
        else e++;
    }
    if(q==n || w==0) puts("-1");
    else
    {
        int mi=e+1;
        if(mi%w==0) mi=mi/w;
        else mi=mi/w+1;
        cout<<mi;
    }

   return 0;
}

发布了84 篇原创文章 · 获赞 19 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/qq_43563669/article/details/104603197