题解归档 - cf706B
本文最后由方少年更新于2026 年 6 月 28 日,已超过0天没有更新。如果文章内容或图片资源失效,请留言反馈,将会及时处理,谢谢!
题解归档 - cf706B
本文由 cf-code 本地题解库自动归档;公开内容以本地 AC/验证版本为准。
- 本地编号:
cf706B - 本地来源:
problems/cf706B/idea.md - 题目链接:https://codeforces.com/contest/706/problem/B
- 原始标题:CF706B — Interesting drink
思路
CF706B — Interesting drink
题意
n 家店价格 x_i,q 天每天预算 m_i,问当天有多少家店价格 ≤ m_i。
做法
价格排序后,每次 upper_bound 求 ≤ m_i 的个数。
验证
样例通过;边界:m 小于最小价输出 0,大于等于最大价输出 n。
代码
来源:problems/cf706B/solution.cpp
/* Author: likely
* Time: 2026-06-08 06:02:15
**/
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll s[100005];
ll n,q,i,j,k,cur,ans;
int main(){
cin>>n;
for(i=1;i<=n;i++) cin>>s[i];
sort(s+1,s+n+1);
cin>>q;
while(q--){
cin>>cur;
ans=upper_bound(s+1,s+n+1,cur)-s-1;
cout<<ans<<"\n";
}
return 0;
}
~ ~ The End ~ ~
文章标题:题解归档 - cf706B
文章链接:https://www.fangshaonian.cn/archives/373/
最后编辑:2026 年 6 月 28 日 19:08 By 方少年
许可协议: 署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)