CodeForces 493C Vasya and Basketball

python爬虫自动下载网页链接 需求分析 今天遇到一个简单的需求,需要下载澳大利亚电力市场NEM日前市场的发电商报价数据(http://nemweb.com.au/Reports/Current/Next_Day_Offer_Energy/),页面观感是这样的: Ctrl + F 一下,看到一共有395个zip链接。于是就想着用python爬虫自动下载。这个网页很简单,没有验证码,甚至不需要登录,因此自动下载的pytho... 阅读详情
C. Vasya and Basketball
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Vasya follows a basketball game and marks the distances from which each team makes a throw. He knows that each successful throw has value of either 2 or 3 points. A throw is worth 2 points if the distance it was made from doesn't exceed some value of d meters, and a throw is worth 3 points if the distance is larger than d meters, where d is some non-negative integer.

Vasya would like the advantage of the points scored by the first team (the points of the first team minus the points of the second team) to be maximum. For that he can mentally choose the value of d. Help him to do that.

Input

The first line contains integer n (1 ≤ n ≤ 2·105) — the number of throws of the first team. Then follow n integer numbers — the distances of throws ai (1 ≤ ai ≤ 2·109).

Then follows number m (1 ≤ m ≤ 2·105) — the number of the throws of the second team. Then follow m integer numbers — the distances of throws of bi (1 ≤ bi ≤ 2·109).

Output

Print two numbers in the format a:b — the score that is possible considering the problem conditions where the result of subtraction a - b is maximum. If there are several such scores, find the one in which number a is maximum.

Sample test(s)
input
3
1 2 3
2
5 6
output
9:6
input
5
6 7 8 9 10
5
1 2 3 4 5
output
15:10

题目大意:a,b两队投篮,给出各自投篮时距篮筐的距离,找一个三分线的位置使得A队得分-B队得分最大,如果差值相等,找使A对得分高的三分线,求出比分。

解题思路:以A,B队的投篮位置枚举三分线,通过计算可知B队2分个数-A队2分个数(用cur记录)最大时满足条件,比较求出答案。

解题过程:wa点:考虑cur值相同时的交换条件。注意容易超时,采用效率高的算法或优化。

代码如下:
#include <cstdio>
#include <algorithm>
using namespace std;
#define LL long long
const int maxn=2000005;
int n,m;
LL a[maxn],b[maxn], c[maxn];
int main()
{
    int k,i,j,sk,sj,maxx=-4000010,cur,an=0,bn=0,cnt=0;
    LL ans1,ans2;
    scanf("%ld",&n);
    for(i=0;i<n;i++)
    {
        scanf("%lld",&a[i]);
        c[cnt++]=a[i];
    }
    sort(a,a+n);
    scanf("%ld",&m);
    for(i=0;i<m;i++)
    {
        scanf("%lld",&b[i]);
        c[cnt++]=b[i];
    }
    sort(b,b+m);
    sort(c,c+cnt);
    cnt=unique(c,c+cnt)-c;//把要枚举的三分线不重复地存入数组c[]中。
    c[cnt]=c[cnt-1]+1;
    cnt++;
    sk=0,sj=0;
    for(i=0;i<cnt;i++)
    {
        if(a[n-1]<c[i])//A队小于三分线的距离个数,即2分个数为k
            k=n;
        else
        for(k=sk;k<n;k++)
            if(a[k]>=c[i])
            {
                sk=k;
                break;
            }
        if(b[m-1]<c[i])//B队小于三分线的距离个数,即2分个数为j
            j=m;
        else
        for(j=sj;j<m;j++)
            if(b[j]>=c[i])
            {
                sj=j;
                break;
            }
		cur=j-k;
        if(maxx<cur||(maxx==cur&&(m-j)>(n-k)))//注意判断条件
        {
            maxx=cur;
            an=k;
            bn=j;
        }
    }
    ans1=2*an+3*(n-an);
    ans2=2*bn+3*(m-bn);
    printf("%lld:%lld\n", ans1,ans2);
    return 0;
}


Altium Designer实战:手把手教你设计智能车竞赛疯狂电路组赛道(附封装库) 本文详细介绍了使用Altium Designer软件进行智能车竞赛“疯狂电路”组赛道设计的全流程实战指南。从理解比赛规则、搭建设计环境、创建专用元器件封装库,到电路布局、路径规划及设计输出验证,手把手教你高效完成符合计分标准的赛道图纸设计,并附上实用的封装库管理方法。 阅读详情

相关推荐

SCL3400-D01双轴高精度倾角计

简介 两轴高精度加速度计,提供两个模式。 ±30° with 10 Hz LPF ±90° with 40 Hz LPF Resolution up to 32768 LSB/g Ultra-low 0.0009°/√Hz noise density 这款传感器是替换之前村田的停产的模拟量系列的芯片,正在测试中,具体效果大伙可以评测。 一、引脚连接图 引脚图兼容SCL3300 二、SPI接口 1.SCL3300和SCL3400略有区别如下图 左边为SCL3...

专注惯导领域 3807

codeforces 493C Vasya and Basketball(二分)

codeforces 493C Vasya and Basketball(二分) 题目大意: 有2个队打篮球,然后告诉你,A队投了N次蓝,分别的距离,B队投了M篮,分别的距离。 As we all know, 篮球有个三分线,然后让你找一个三分线出来,使得A队的得分-B队得分最大。差值相同的情况下,找比分最大的。 压线算2分。

tsxhl111的专栏 1178

Windows系统3D Gaussian Splatting环境搭建全攻略:从零开始到成功运行

本文详细介绍了在Windows系统上搭建3D Gaussian Splatting环境的完整流程,包括CUDA 12.6安装、Anaconda环境配置、代码获取与依赖安装等关键步骤。针对Windows平台特有的环境配置问题,提供了实用的解决方案和常见错误排查方法,帮助开发者快速实现3D Gaussian Splatting的成功运行。

weixin_30832143的博客 452

Codeforces 493C Vasya and Basketball(暴力)

题目链接:Codeforces 493C Vasya and Basketball #include #include #include #include using namespace std; const int inf = 0x3f3f3f3f; struct state { int t, s; state(int t = 0, int s = 0) { this->t

不慌不忙、不急不躁 950

HBF凭什么能挑战HBM?

最近AI圈聊得最多的,除了大模型迭代,就是“算力瓶颈”。大家都知道GPU不够用、HBM抢疯了,但很少有人注意到,存储层正在酝酿一场革命——高带宽闪存(HBF)。今天就结合HBM之父Joungho Kim教授的最新观点,跟大家好好盘盘这门技术:它不是HBM的替代品,却可能重塑AI推理的游戏规则,甚至在2038年超越HBM市场规模。先澄清一个核心认知:HBF不是凭空冒出来的新技术,而是站在HBM肩膀上的“优化款”。

存储随笔 2129

从零到一:Qt与PCL的跨平台开发环境搭建全攻略

本文详细介绍了从零开始搭建Qt与PCL跨平台开发环境的完整流程,涵盖Windows、Linux和macOS三大平台。重点解析了Qt5与Qt6版本选择、PCL库安装配置、VTK集成等关键技术要点,并提供跨平台CMake项目模板和常见问题解决方案,助力开发者快速构建三维点云处理应用。

weixin_29280657的博客 382

codeforces 493C Vasya and Basketball

传送门: cf 493C 给定两只队伍进球数以及每一次进球离篮筐的距离。现在可以人为控制三分线,问怎样设定三分线能使得a队分数在尽量大的情况下相对于b队分数最优。 枚举a队的距离作为三分线并用二分求b队的得分,求最优情况下的对应分数 /****************************************************** * File Name: c.cp

飞火扑蛾的专栏 648

FFmpeg视频编码的流程详解及参考demo

本文主要讲解FFmpeg的视频编码的具体流程,API使用。最后再以一个非常简单的demo演示将一个yuv数据文件编码为H264的视频文件,也就是YUV编码为H264。

分享音视频技术 4498

codeforces 493C Vasya and Basketball(枚举)

题目链接 Vasya and Basketball time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vasya follows a basketball g

madaidao的专栏 786

【笔试真题】- 华子-2025.12.17-研发岗

难度:中等难度:中等偏难难度:中等K小姐是一名服务器运维工程师,她负责监控公司服务器的访问日志。服务器采用指数退避策略来优化访问频率,每次重试的时间间隔会按照某种规律增长。经过一段时间的监控,K小姐记录了 nnn 个访问时间点,第 iii 个时间点的值为 a[i]a[i]a[i](可能有重复)。现在,她想分析这些访问时间点是否符合某种特定的模式。具体来说,对于给定的参数对 (x,y)(x, y)(x,y),她想知道:有多少个访问时间点 a[i]a[i]a[i] 满足 a[i]=xK+ya[i] = x^K

春秋招笔试突围 185

61、神经科学中的分岔与双分子反应研究

本文探讨了神经科学中的分岔现象与双分子反应建模。在神经元网络中,通过分析四细胞网络的呼吸节律振荡,揭示了分岔对振荡频率和占空比的影响,并区分了单神经元与网络层面的分岔特性。在神经群体模型中,系统参数变化引发的分岔可导致振荡、混沌等动态行为转变,文中详细介绍了局部分岔、全局分岔和高余维分岔的机制,并以Jansen-Rit模型为例展示了输入水平变化下的分岔过程。在分子层面,重点介绍了MWC模型在描述配体与多位点蛋白质结合中的应用,涵盖其构象状态、平衡常数及统计因子。研究表明,分岔理论和双分子反应建模为理解神经系

yog99的博客 80

【Codeforces 493C】Vasya and Basketball

【链接】 我是链接,点我呀:) 【题意】 题意 【题解】 枚举三分线(离散后)的位置 然后根据预处理的前缀和,快速算出两个队伍的分数。 【代码】 #include <bits/stdc++.h> using namespace std; const int N = 2e5; int n,m; int a[N+10],b[N+10],aa[2*N+100]...

AWCXV 155

【PCIe 总线及设备入门学习专栏 3.2.2 -- PCIe 中什么是 SR-IOV】

SR-IOV(Single Root I/O Virtualization)是 PCIe 规范中的一种技术,允许物理 PCIe 设备(称为 Physical Function, PF)虚拟化为多个虚拟设备(称为 Virtual Functions, VFs),使多个操作系统或虚拟机能够共享同一个物理设备。SR-IOV:一种 PCIe 虚拟化技术,允许将一个物理 PCIe 设备虚拟化为多个虚拟设备。:物理设备的主要管理接口。:PF 的轻量级副本,分配给虚拟机或操作系统。

CodingCos的博客 1513

Codeforces 493C - Vasya and Basketball

C. Vasya and Basketball 题目链接:http://codeforces.com/problemset/problem/493/C time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard ou...

weixin_34092455的博客 174

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

codeforces493 A. Vasya and Football B. Vasya and Wrestling C. Vasya and Basketball

A. Vasya and Football 这个题目很简单,只需要按照提议模拟一下即可,注意模拟的时候要先按照时间排序,一旦某个人已经被提示红牌,就不在对其考虑; #include #include #include #include #define MAX 110 #define ll __int64 using namespace std; char sname[30], tname[

ZT在努力 547

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

CodeForces 493C C. Vasya and Basketball 二分

传送门:C. Vasya and Basketball题目大意第一只队伍有N的个人投篮,第二个人有M个人投篮,为了让第一只队伍和第二只队伍的分差尽可能大,怎么选定三分线解题思路对两只队伍的每个距离进行二分,判断最大分差,还有判断两只队伍都是投三分球和都是投二分球的进行判断AC代码#include<cstdio> #include<cstring> #include<algorithm> using

woshinannan的专栏 482

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

Codeforces 493C. Vasya and Basketball【暴力+二分】

C. Vasya and Basketball time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vasya follows a basketball game and marks the

mengxiang000000 789

CodeForces 493C Vasya and Basketball(模拟 + 二分)

C - Vasya and Basketball Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 493C Description Vasya follows a basketball g

qq_18661257的专栏 910

Vasya and Basketball codeforces 493c 二分二分

B - Vasya and Basketball Crawling in process... Crawling failed Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u   Vasya follows a basketball game and marks the di

qiuxueming_csdn 535

codeforces 493C Vasya and Basketball (枚举+模拟+思维)

codeforces的思维模拟,很有意思

Tc的专栏 1624

CF_493 C- Vasya and Basketball(二分)

C. Vasya and Basketball time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vasya follows a basketball game and

EaShion1994的专栏 805

codeforces #493C# Vasya and Basketball(二分upper_bound+贪心)

C. Vasya and Basketball time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vasya follows a basketball game and

Algobird 858

Codeforces Round #281 (Div. 2) C. Vasya and Basketball 二分

C. Vasya and Basketball 题目连接: http://codeforces.com/contest/493/problem/C Description Vasya follows a basketball game and marks the distances from which each team makes a throw. He knows that each suc...

weixin_30500289的博客 105
上一篇: CodeForces 496B Secret Combination
下一篇: CodeForces 492D Vanya and Computer Game
雨狮子
博客等级 码龄12年 24粉丝 185原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值