Codeforces Round #625 -前三题题解

本文详细介绍了Codeforces Round #625 分别为A. Contest for Robots、B. Journey Planning和C. Remove Adjacent三题的题意、解题思路和代码实现。作者在反思中提到部分题目可以优化解题方法,并计划深入学习String知识。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Codeforces Round #625 (Div. 2, based on Technocup 2020 Final Round)-A. Contest for Robots
打一场比赛做一个比赛和知识小结。
A. Contest for Robots

A. Contest for Robots

题意:很简单就不写了
思路:
  1. 第一个与第二个答题情况一样时都不选择情况为-1。
  2. 考虑第一个做对同时第二个做错的情况记录为x,第二个做对同时第一个做错的情况记录为y。
    结果就是y/x+1;
    为什么是y/x;对于每一个不够除+1,够除找最合适需要多一个也加1。

做题目时想法
关于这道题目细想:

  1. x==y && x!=0 maxx=2
  2. x>y maxx=1
  3. x==0 -1
  4. 否则 一个循环找

反思:
这个题目其实不需要用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<
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值