codeforces div2 PriceFixed 补题
思路:
贪心 + 排序 + 双指针算法
先按bi的数量从大到小排序,然后排序ai,然后运用双指针,如果购买的商品数可以买最低需要的商品数打折就一直买,否则的话从最后面购买商品使得前面的商品可以构成打折,然后把后面的买完的数量就清除掉。
代码:
```cpp
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long LL;
const int N = 2e5+10;
int t;
typedef pai..
原创
2021-06-21 20:46:33 ·
161 阅读 ·
0 评论