Luogu p1935 题解
来源:互联网 发布:哪有天刀脸数据 编辑:程序博客网 时间:2024/05/03 18:00
#include<iostream>#include<cstdio>#include<cstdlib>#include<algorithm>#include<cmath>#include<queue>#include<cstring>using namespace std;struct node{int v,id;};struct cmp{bool operator ()(node a,node b){ return a.v>b.v;}};priority_queue<node,vector<node>,cmp> q;int ans[20000],a[20000],b[20000],c[20000],d[20000];int n,m;node x,y;int main(){scanf("%d%d",&n,&m);for(int i=1;i<=n;i++){ scanf("%d%d%d",&a[i],&b[i],&c[i]); x.v=a[i]+b[i]+c[i];x.id=i; d[i]=1;q.push(x);}for(int i=1;i<=m;i++){ y=q.top();q.pop(); ans[i]=y.v;d[y.id]++; int t=y.id; x.id=y.id;x.v=a[t]*d[t]*d[t]+b[t]*d[t]+c[t]; q.push(x);}for(int i=1;i<=m;i++){ printf("%d ",ans[i]);}return 0;}
0 0
- Luogu p1935 题解
- [luogu-1007]独木桥 题解
- 【题解】Luogu P1991 无线通讯网
- 【BZOJ】【P1935】【Shoi2007】【Tree 园丁的烦恼】【题解】【树状数组+离散化】
- 邮递员送信(luogu 1629)题解
- 序列合并(luogu 1631)题解
- 【题解】 Luogu P2024 食物链 (并查集)
- [luogu-2678]noip2015day2-T1 跳石头 题解
- [luogu-2679]noip2015day2-T2 子串 题解
- [luogu-2680]noip2015day2-T3 运输计划 题解
- [luogu-1850]noip2016day1-T3 换教室 题解
- [luogu-2877]noip2016-day2-T2 蚯蚓 题解
- LUOGU P2058 海港题解(附代码)
- [luogu-1563]noip2016day1-T1 玩具谜题 题解
- [luogu-2822]noip2016-day2-T1 组合数问题 题解
- [luogu-2831]noip2016-day2-T3 愤怒的小鸟 题解
- [luogu-3379]【模板】最近公共祖先(LCA) 题解
- [luogu-1314]noip2011 day2-T2聪明的质监员 题解
- how to 指定相同ponitcut advisor 的执行顺序
- thread接口,java并发编程
- Java中的路径问题
- bzoj 1059 矩阵游戏
- Mac OS中主要有三种包管理工具
- Luogu p1935 题解
- 顺序表
- XML和JSON的特点
- 剑指Offer_29_最小的K个数
- tar压缩解压缩命令详解
- 配置android studio ----SDK、JDK、NDK路径
- 【查找】折半查找/二分查找
- Android WebView使用解析一
- android 获取各种日期