[codeforces 1321A] Contest for Robots 题目有些长

Codeforces Round #625 (Div. 2, based on Technocup 2020 Final Round)   比赛人数5638

[codeforces 1321A] Contest for Robots   题目有些长

总目录详见https://blog.csdn.net/mrcrack/article/details/103564004

在线测评地址https://codeforces.ml/contest/1321/problem/A

ProblemLangVerdictTimeMemory
A - Contest for Robots GNU C++11Accepted31 ms0 KB

比赛时,有些震撼,作为第一题,题目有些长。比赛开始阶段,还在处理一些业务,耽搁了15分钟,不过,对自己还是有充分的信心,后面的题,总是能做些出来,这还是要归功于这段时间codeforces的比赛,场场不落,铸就的信心

题虽然长,但该题的核心体现在此句

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.

手工算法如下

BionicSolver Industries能处理的值都设置为1

Robo-Coder Inc.能处理的值之和只要比   BionicSolver Industries能处理的值之和   多1即可。 

Input1:
5
1 1 1 0 0
0 1 1 1 1
Output1:
3

     1 1 1 0 0
     0 1 1 1 1
取值 3      1 1
Input4:
9
1 0 0 0 0 0 0 0 1
0 1 1 0 1 1 1 1 0
Output4:
4


      1 0 0 0 0 0 0 0 1
      0 1 1 0 1 1 1 1 0
取值  4  1 1  1 1 1 1  3  

AC代码如下

#include <stdio.h>
#define maxn 105
int a[maxn],b[maxn];
int main(){
	int n,i,cnt1=0,cnt2=0;//>0 cnt1;<0 cnt2
	scanf("%d",&n);
	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++)a[i]-=b[i];
	for(i=1;i<=n;i++)
		if(a[i]>0)cnt1++;
		else if(a[i]<0)cnt2++;
	if(cnt1==0)printf("-1\n");
	else printf("%d\n",cnt2/cnt1+1);
	return 0;
}

 

 

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值