|洛谷|堆|P1631 序列合并
来源:互联网 发布:最难就业的专业 知乎 编辑:程序博客网 时间:2024/06/06 03:48
https://www.luogu.org/problem/show?pid=1631
在lrj的蓝书上有详细介绍
#include<cstdio>#include<algorithm>#include<cstring>#include<queue>#define ms(i,j) memset(i,j, sizeof i);using namespace std;int n;int A[100005], B[100005];struct node{ int sum; int no; node (int s, int n) : sum(s), no(n){}};struct cmp{ bool operator()(node a, node b) { return a.sum>b.sum; }};int d[100005];priority_queue<node, vector<node>, cmp> p;int main(){ scanf("%d", &n); for (int i=1;i<=n;i++) scanf("%d", &A[i]); for (int i=1;i<=n;i++) scanf("%d", &B[i]); for (int i=1;i<=n;i++) { d[i] = 1; p.push(node(A[i]+B[d[i]], i)); } int tot = 0; while (tot<n) { node c = p.top();p.pop(); printf("%d ", c.sum); d[c.no]++; tot++; p.push(node(A[c.no]+B[d[c.no]], c.no)); } return 0;}
0 0
- |洛谷|堆|P1631 序列合并
- 洛谷 P1631 序列合并
- 洛谷P1631 序列合并
- 洛谷P1631 序列合并
- 洛谷 P1631 序列合并
- 洛谷 P1631 序列合并
- 洛谷P1631 序列合并
- 洛谷 P1631 序列合并
- 洛谷P1631 序列合并
- 洛谷 P1631 序列合并
- P1631 序列合并
- [luogu]P1631序列合并-堆排的套路运用
- [洛谷P1631]序列合并/[codevs1245]最小的N个和
- 洛谷 堆专题 序列合并
- 序列合并 洛谷1631 堆
- 洛谷 1631 序列合并 堆 解题报告
- 堆or优先队列(洛谷1631 序列合并)
- 【洛谷】P1628 合并序列
- Qt学习心得-FFTW3在Qt5.7下的安装
- JS 考试倒计时
- Flex调试安卓应用设备脱机
- java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
- 人脸识别 - A Discriminative Feature Learning Approach for Deep Face Recognition
- |洛谷|堆|P1631 序列合并
- 函数指针与指针函数
- 日志监控及Redis存储
- Android定制--------开机对话框的实现
- Git图形界面的使用
- RAD Studio D10发布IOS TestFlight不支持外部测试的解决方法
- |洛谷|堆|P3045 [USACO12FEB]牛券Cow Coupons
- 网络专业化销售流程
- STM32之启动模式