lower_bound
MasterSPP
这个作者很懒,什么都没留下…
展开
-
烦恼的高考志愿--lower_bound解法
##烦恼的高考志愿 输入 4 3 513 598 567 689 500 600 550 输出 32 首先需要理解lower_bound的用法,参考lower_bound和upper_bound用法 #include<bits/stdc++.h> using namespace std; int a[1000005], b[1000005]; int main(){ int m, n, sum = 0; cin>>m>>n; a[0] = -1000000原创 2021-03-10 13:14:50 · 294 阅读 · 3 评论 -
lower_bound和upper_bound 用法
lower_bound和upper_bound 用法 只适用于一串递增序列 lower_bound(迭代器_1, 迭代器_2, x):返回指向a中第一个 【大于等于】 x的元素的迭代器 upper_bound(迭代器_1, 迭代器_2, x):返回指向a中第一个 【大于】 x的元素的迭代器 举例: int a[] = {1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4}; cout << (lower_bound(a, a + 12, 4) - a) << end原创 2021-03-08 22:07:55 · 173 阅读 · 0 评论