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 the***panies, 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;
}

全部评论

相关推荐

03-24 13:24
已编辑
江西农业大学 后端工程师
最近或许大家都听说xxxx厂裁员,无论前端,后端,大数据,测试,运维,人人可危,&nbsp;“前端死了,后端也死了,JAVA崩盘了,你们这群搞大模型的真是码奸”这次AI真的会让我们无路可走吗????????太阳底下已经没有新鲜事了旧的生产力的消失,必然有新的生产力诞生马车夫消失&nbsp;→&nbsp;汽车司机、修车工、石油工业诞生,从业人数是马车夫的百倍手工纺织女工消失&nbsp;→&nbsp;纺织机械工程师、面料设计师诞生,纺织品产量提升百倍2007年苹果开放&nbsp;App&nbsp;Store,&quot;移动端开发者&quot;这个职业压根不存在。八年后,全球应用经济规模突破&nbsp;1000亿美元,凭空诞生了数百万开发者岗位。每一次&quot;这次真的完了...
二十岁的编程男神王大...:那这个时代是什么时代呢? 是全员agent的时代,是前端+AI,后端+AI的时代,AI已经融入了项目生命周期的的每一个角落,那我最近在做的东西举例,检查BUG时,我们会用codex,CC等工具的skill去check,效果好还能直接fix,测试的时候,apifox等工具已经有了AI落地的改造,CI/CD阶段,我们会根据hook去跑AI check脚本,就连不少中间件,也迎来了AI落地的改造,(AI网关,AI在MQ中的运用),都可以去了解下 另外记着,这些东西不是意义,工作只是谋生的一个手段,ai是让开发提效了,但是呢,原先一周的工作流程压缩到了两天内,同时低级的都裁员了,只有高级的去维护,你看似写的大义凛然,或许那天你也会成为你文章里面拒绝往前走的人,你才大二,面对技术有热情是对的
AI求职实录
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
正在热议
更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务