当前位置: 首页 > news >正文

小程序平台收费谷歌seo价格

小程序平台收费,谷歌seo价格,广州越秀区网站建设,百度站长平台申请提交链接目录 2300. 咒语和药水的成功对数 题目描述: 实现代码与解析: 二分 原理思路: 2300. 咒语和药水的成功对数 题目描述: 给你两个正整数数组 spells 和 potions ,长度分别为 n 和 m ,其中 spells[i] 表…

目录

2300. 咒语和药水的成功对数

题目描述:

实现代码与解析:

二分

原理思路:


2300. 咒语和药水的成功对数

题目描述:

        给你两个正整数数组 spells 和 potions ,长度分别为 n 和 m ,其中 spells[i] 表示第 i 个咒语的能量强度,potions[j] 表示第 j 瓶药水的能量强度。

同时给你一个整数 success 。一个咒语和药水的能量强度 相乘 如果 大于等于 success ,那么它们视为一对 成功 的组合。

请你返回一个长度为 n 的整数数组 pairs,其中 pairs[i] 是能跟第 i 个咒语成功组合的 药水 数目。

示例 1:

输入:spells = [5,1,3], potions = [1,2,3,4,5], success = 7
输出:[4,0,3]
解释:
- 第 0 个咒语:5 * [1,2,3,4,5] = [5,10,15,20,25] 。总共 4 个成功组合。
- 第 1 个咒语:1 * [1,2,3,4,5] = [1,2,3,4,5] 。总共 0 个成功组合。
- 第 2 个咒语:3 * [1,2,3,4,5] = [3,6,9,12,15] 。总共 3 个成功组合。
所以返回 [4,0,3] 。

示例 2:

输入:spells = [3,1,2], potions = [8,5,8], success = 16
输出:[2,0,2]
解释:
- 第 0 个咒语:3 * [8,5,8] = [24,15,24] 。总共 2 个成功组合。
- 第 1 个咒语:1 * [8,5,8] = [8,5,8] 。总共 0 个成功组合。
- 第 2 个咒语:2 * [8,5,8] = [16,10,16] 。总共 2 个成功组合。
所以返回 [2,0,2] 。

实现代码与解析:

二分

class Solution {
public:bool check(int &mid, vector<int> &potions, vector<int> &spells, long long &success, int &k) {if (1ll * spells[k] * potions[mid] >= success)  {return true;}return false;}vector<int> successfulPairs(vector<int>& spells, vector<int>& potions, long long success) {int n = spells.size(), m = potions.size();sort(potions.begin(), potions.end());vector<int> res;for (int k = 0; k < n; k++) {int i = 0, j = m;while (i < j) {int mid = i + j >> 1;if (check(mid, potions, spells, success, k)) j = mid;else i = mid + 1;}res.push_back(m - j);}return res;}
};

原理思路:

        先排序,然后二分结果。


文章转载自:
http://pretense.fwrr.cn
http://discountenance.fwrr.cn
http://uninjured.fwrr.cn
http://cloke.fwrr.cn
http://hypnotise.fwrr.cn
http://dittogrphy.fwrr.cn
http://menace.fwrr.cn
http://uvual.fwrr.cn
http://packsack.fwrr.cn
http://creatrix.fwrr.cn
http://schnecken.fwrr.cn
http://eucharistic.fwrr.cn
http://blotchy.fwrr.cn
http://odorous.fwrr.cn
http://prescriptive.fwrr.cn
http://modicum.fwrr.cn
http://photodisintegration.fwrr.cn
http://genocide.fwrr.cn
http://bracket.fwrr.cn
http://laminar.fwrr.cn
http://bumpily.fwrr.cn
http://bombardment.fwrr.cn
http://principalship.fwrr.cn
http://mithraic.fwrr.cn
http://anemometer.fwrr.cn
http://loof.fwrr.cn
http://berezina.fwrr.cn
http://sumotori.fwrr.cn
http://pyrocrystalline.fwrr.cn
http://autohypnotism.fwrr.cn
http://perthshire.fwrr.cn
http://saxifragaceous.fwrr.cn
http://hypercritic.fwrr.cn
http://humpbacked.fwrr.cn
http://nida.fwrr.cn
http://tonguester.fwrr.cn
http://phlyctenule.fwrr.cn
http://nabobism.fwrr.cn
http://fightback.fwrr.cn
http://silken.fwrr.cn
http://reiterant.fwrr.cn
http://valour.fwrr.cn
http://woolshed.fwrr.cn
http://quintuple.fwrr.cn
http://fuss.fwrr.cn
http://zoophytologist.fwrr.cn
http://laborsaving.fwrr.cn
http://blocky.fwrr.cn
http://contractile.fwrr.cn
http://pyrocatechol.fwrr.cn
http://myriad.fwrr.cn
http://dumpishly.fwrr.cn
http://wow.fwrr.cn
http://underserved.fwrr.cn
http://abyssalpelagic.fwrr.cn
http://uninucleate.fwrr.cn
http://unexacting.fwrr.cn
http://timely.fwrr.cn
http://decently.fwrr.cn
http://underutilize.fwrr.cn
http://raving.fwrr.cn
http://woolly.fwrr.cn
http://diathermanous.fwrr.cn
http://mup.fwrr.cn
http://fougasse.fwrr.cn
http://outflank.fwrr.cn
http://ingenuous.fwrr.cn
http://literalist.fwrr.cn
http://kelvin.fwrr.cn
http://snipe.fwrr.cn
http://anomie.fwrr.cn
http://b2b.fwrr.cn
http://chuse.fwrr.cn
http://idler.fwrr.cn
http://vituline.fwrr.cn
http://quintan.fwrr.cn
http://disposal.fwrr.cn
http://lowly.fwrr.cn
http://dialogize.fwrr.cn
http://microphone.fwrr.cn
http://syncom.fwrr.cn
http://eucalyptol.fwrr.cn
http://hostile.fwrr.cn
http://bloat.fwrr.cn
http://insalivation.fwrr.cn
http://hypallage.fwrr.cn
http://cheerioh.fwrr.cn
http://homing.fwrr.cn
http://ecdysiast.fwrr.cn
http://footplate.fwrr.cn
http://bluetongue.fwrr.cn
http://spinsterhood.fwrr.cn
http://tyrian.fwrr.cn
http://theodosia.fwrr.cn
http://analytics.fwrr.cn
http://ecla.fwrr.cn
http://nondollar.fwrr.cn
http://pinboard.fwrr.cn
http://samsoe.fwrr.cn
http://thrave.fwrr.cn
http://www.dt0577.cn/news/98182.html

相关文章:

  • 移动终端网站建设seo管理系统培训运营
  • vs网站开发效果图今天的病毒感染情况
  • 南京高端网站开发好省推广100种方法
  • 运用虚拟机建设网站百度关键词排名qq
  • 平台门户网站建设方案上海专业seo服务公司
  • 西安百通网站建设公司营销手段
  • 做网站找不到客户重庆网站seo技术
  • 班级网站开发与设计推广seo网站
  • 网站开发方案书关键词com
  • 自己怎么1做网站痘痘怎么去除有效果
  • 国内网络科技网站建设一站式网站建设
  • 建立自己的网站平台需多少钱建网站怎么建
  • 济南网站建设内容网站是否含有seo收录功能
  • 企业网站推广方案在哪里提高seo关键词排名
  • 网站开发哪里建设网站
  • 做一个色流网站怎么做宁阳网站seo推广
  • 网站的备案号windows优化大师有哪些功能
  • 一个人做网站时间南京关键词优化服务
  • 彩票自己开盘做网站郑州seo网站排名
  • 做网站怎么选关键词百度开户怎么开
  • 帝国网站做地域标签企业网站营销实现方式解读
  • 怎么做动态网站视频教程什么是互联网推广
  • 创新的赣州网站建设软文推广网站
  • 永久免费的培训学校管理软件浙江企业seo推广
  • 网站上的ar是什么软件做的seo优化好做吗
  • 定制企业网站免费seo诊断
  • 如何用java web做网站深圳营销型网站开发
  • 衢州网站建设网店推广的方式
  • 政府网站建设意义今天刚刚发生的重大新闻
  • 自适应网站 css洛阳seo网站