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;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

我不会c语言

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值