H - 小明喝奶茶
正解是用一个权值线段树什么的维护一下,取一下第K小值,但是我不会。只能打打暴力,发现数据比较水,也能过,就当练练模拟了。
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32#include<bits/stdc++.h> using namespace std; typedef pair<int,int> PII; const int N = 100010; vector<PII> d[N]; signed main() { int n,m,k;cin>>n>>m>>k; for(int i=1;i<=m;i++) { int l,r,c,p;cin>>l>>r>>c>>p; for(int j=l;j<=r;j++) d[j].push_back({p,c}); } for(int i=1;i<=n;i++) sort(d[i].begin(),d[i].end()); int res=0; for(int i=1;i<=n;i++) { int p=k; for(auto &[a,b]:d[i]) if(p>=b) res+=a*b,p-=b; else { res+=a*p; break; } } cout<<res; return 0; }
最后
以上就是含蓄书包最近收集整理的关于2022河南萌新联赛第(五)场:信息工程大学 H - 小明喝奶茶H - 小明喝奶茶的全部内容,更多相关2022河南萌新联赛第(五)场:信息工程大学内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复