文章目录
Codeforces Round #625 (Div. 2, based on Technocup 2020 Final Round)-A. Contest for Robots
打一场比赛做一个比赛和知识小结。
A. Contest for Robots
A. Contest for Robots
题意:很简单就不写了
思路:
- 第一个与第二个答题情况一样时都不选择情况为-1。
- 考虑第一个做对同时第二个做错的情况记录为x,第二个做对同时第一个做错的情况记录为y。
结果就是y/x+1;
为什么是y/x;对于每一个不够除+1,够除找最合适需要多一个也加1。
做题目时想法
关于这道题目细想:
- x==y && x!=0 maxx=2
- x>y maxx=1
- x==0 -1
- 否则 一个循环找
反思:
这个题目其实不需要用for枚举的,自己思路不够好
手速慢,细想花时间也有点多了。
代码1
#include <bits/stdc++.h>
#define pb(a) push_back(a)
#define pf push_front
#define beg begin
#define e end
#define rb rbegin0
#define re rend
#define nd cout<<endl
#define all(s) s.begin(),s.end()
#define pi acos(-1.0)
#define MaxN 0x3f3f3f3f
#define MinN 0xc0c0c0c0
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const int N=2e5+15;
int n,a[N];
int c[N],b[N];
int main()
{
cin>>n;
int ans=0,cnt=0;
for(int i=0; i<n; i++)
{
cin>>a[i];
}
for(int j=0; j<n; j++)
{
cin>>b[j];
}
for(int i=0; i<n; i++)
{
if(b[i]==1&&a[i]!=1)
{
ans++;
}
else if(a[i]==1&&b[i]!=1)
{
cnt++;
}
}
if((ans==0&&cnt==0)||cnt==0)
cout<<"-1"<<endl;
else if(ans==cnt)
cout<<"2"<<endl;
else if<