首页 > 其他分享 >CF390B Inna, Dima and Song Solution

CF390B Inna, Dima and Song Solution

时间:2023-11-05 09:04:25浏览次数:39  
标签:Dima Song int Solution long CF390B

转裁自我的洛谷博客 :https://www.luogu.com.cn/blog/653832/solution-cf390b

题目传送门

思路:

  1. 如果 $b_i \le 1$ 则无解。
  2. 如果 ceil((double)b[i]/2)>a[i],即最好情况下,两个人的音量平均,但是较大的音量还是大于 $a_i$。那么也是无解的。
  3. 否则,要使他们的乘积最大,两个数就要尽量接近。先除以 $2$,然后一个向上取整,一个向下取整即可。

特别地,因为 $10^6 \times 10^6 $ 会爆 int,所以 ans 要开 long long。

核心代码:

for(int i=1;i<=n;i++)
{
	if(ceil((double)b[i]/2)>a[i]||b[i]<=1)ans--;
	else ans+=ceil((double)b[i]/2)*floor((double)b[i]/2);
}

标签:Dima,Song,int,Solution,long,CF390B
From: https://www.cnblogs.com/UshioNoa/p/solution-cf390b.html

相关文章

  • Viper —— configuration solution for Go
    1.supportseveralformatsofconfigurationconfig.yamlname:'bobby'port:12334main.gotoquickstart packagemainimport("fmt""github.com/spf13/viper")typeServerConfigstruct{ServiceNamestring......
  • Solution to OpenSSL Connection Problems With Github
    ProblemsUploadingFileswithGitSometimeswecanusegittooltosuccessfullyuploadprojectstoGithub,butinothertimeespeciallyafteraperiodofconfiguration,weoftenmeetthefollowingerror:OpenSSLSSL_read:Connectionwasreset,error10054......
  • Practice Assessment for Exam AZ-400: Designing and Implementing Microsoft DevOps
    https://learn.microsoft.com/en-us/credentials/certifications/exams/az-400/practice/assessment?assessment-type=practice&assessmentId=56 Themostsecurewaytopasssecretstoruncommandsistoreferencethemasenvironmentvariables,ratherthana......
  • Autofac.Core.DependencyResolutionException-DefaultObjectMapper
    异常: 解决方法在模块配置AutoMapper的配置文件处修改validate参数的值true改为false ......
  • Solution
    谁共一杯芳酒按\(l\)从大到小为第一关键字,\(r\)从小到大为第二关键字排序,以\(r\)为权值求最长不下降子序列即可。代码#include<cstdio>#include<vector>#include<queue>#include<cstring>#include<iostream>#include<algorithm>#include<ctime>#include<......
  • The solution of P9194
    10黑寄。problem&blog考虑到处理加边并不简单,所以我们可以考虑一个黑点\(p\),连边\((u,p)(p,v)\)。考虑在现在这棵树上连个点在原图中有变相连相当于有一个公共的\(p\)是它们的邻居。于是删边操作等价于将一个点的儿子黑点并到父亲黑点上。为了统计答案我们设\(x\)为......
  • CF1854C Solution
    题目链接题意给定大小为\(n\)的正整数集合\(S\),\(S\)中的每个数在\(1\simm\)之间。每一秒进行如下操作:从\(S\)中等概率随机选择一个数\(x\)。将\(x\)从\(S\)中删去。若\(x+1\leqm\)且\(x+1\notinS\),则将\(x+1\)加入\(S\)。求\(S\)变成空集......
  • Argument for '--moduleResolution' option must be: 'node', Unknown compiler opt
    node_modules/@vue/tsconfig/tsconfig.json(12,25):errorTS6046:Argumentfor'--moduleResolution'optionmustbe:'node','classic','node16','nodenext'.node_modules/@vue/tsconfig/tsconfig.json(33,5):erro......
  • IDM:Implicit Diffusion Models for Continuous Super-Resolution超分辨率
    摘要当今超分辨领域的模型普遍存在过度平滑(难以保持放大后图像的锐利和纹理,导致高频信息丢失和视觉上变得平滑)和伪影(生成的高分辨率图像中可能出现的不希望出现的失真或瑕疵,包括模糊、马赛克效应或者不自然纹理等)的现象,作者据此提出了IDM模型,IDM模型是在一个统一的端到端框架中集......
  • Perkins 1106D Generation CID 0003 FMI 05 Trouble Code Solution
     ThisillustrationgivethesolutionforPerkins1106Delectricpowergeneration(EPG)CID0003FMI05troublecode.RelatedContents:PerkinsESTCompactAdapterPerkinsEST2023A&2022A&2019ASoftwareFreeDownloadPerkins1106DElectricPower......