codeforce 853A Planning
题目地址:http://codeforces.com/problemset/problem/853/A
题目大意:
本来安排了 n 架飞机,每架飞机有 ci 的重要度,
第 i 架飞机的起飞时间为 i ,而现在,在 k 时之前不能有任何飞机起飞,每个时间点只有1架飞机能起飞,
损失=(飞机现起飞时间-飞机原起飞时间)*该飞机的重要度.
现在要求你排一张时间表,要求每架飞机都只能在原起飞时间及以后起飞,且使损失最小.
题解:
贪心
暴力的数组模拟tle,o(≧口≦)o
#include<bits/stdc++.h>
using namespace std;
int n,k; struct node
{
int id;
long long c;
}a[];
int b[],ans[];
bool vis[];
long long sum;
bool cmp(node a,node b)
{
if (a.c!=b.c) return a.c>b.c;
else return a.id>b.id;
} int main()
{
scanf("%d%d",&n,&k);
for(int i=;i<=n;i++)
{
scanf("%d",&a[i].c);
a[i].id=i;
}
sort(a+,a++n,cmp);
for(int i=;i<=n;i++) {b[i]=k+i; vis[i]=;}
sum=;
for(int i=;i<=n;i++)
{
int t=;
while()
{
int kk=lower_bound(b+t+,b++n,a[i].id)-b;
if (!vis[kk]) { vis[kk]=; sum+=(b[kk]-a[i].id)*a[i].c; ans[a[i].id]=b[kk]; break;}
else t=kk;
}
}
printf("%lld\n",sum);
for(int i=;i<=n;i++)
{
if (i-) printf(" ");
printf("%d",ans[i]); }
printf("\n");
return ;
}
codeforce 853A Planning的更多相关文章
- CodeForces - 853A Planning (优先队列,贪心)
Helen works in Metropolis airport. She is responsible for creating a departure schedule. There are n ...
- Codeforces 853A Planning
题意 给出飞机单位晚点时间代价和原定起飞时间,现在前k分钟不能起飞,求付出的最小代价和起飞顺序 思路 构造两个优先队列q1,q2,q1按时间顺序,q2按代价顺序,初始将所有飞机入q1,将时间在k前的飞 ...
- (codeforces 853A)Planning 贪心
Helen works in Metropolis airport. She is responsible for creating a departure schedule. There are n ...
- 敏捷转型历程 - Sprint3 Planning
我: Tech Leader 团队:团队成员分布在两个城市,我所在的城市包括我有4个成员,另外一个城市包括SM有7个成员.另外由于我们的BA离职了,我暂代IT 的PO 职位.PM和我在一个城市,但他不 ...
- HOW TO RUN A SPRINT PLANNING MEETING (THE WAY I LIKE IT)
This is a sample agenda for a sprint planning meeting. Depending on your context you will have to ch ...
- Tips for Planning Your Business Startup
原文链接:http://domaintree.me/?p=1037 By Robert Thibodeau – Starting a business can be a very daunting ...
- Employment Planning[HDU1158]
Employment Planning Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- Software Engineering: 3. Project planning
recourse: "Software Engineering", Ian Sommerville Keywords for this chapter: planning sche ...
- 运动规划 (Motion Planning): MoveIt! 与 OMPL
原创博文:转载请标明出处:http://www.cnblogs.com/zxouxuewei 最近有不少人询问有关MoveIt!与OMPL相关的话题,但是大部分问题都集中于XXX功能怎么实现,XXX错 ...
随机推荐
- Python3基础 json.loads 解析json格式的数据,得到一个字典
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- Python3基础 父,子类普通方法重名 子类方法覆盖父类方法
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- Facebook广告API系列 3 Ads Management
Facebook广告API系列 3 Facebook marketing API有三大组成部分: Audience Management Ads Management Ads Insights 本篇介 ...
- Ubuntu16.04 无法连接WiFi
在安装完 ns-3.25 之后,着手开始准备 Eclipse 的安装,打开了 Firefox游览器 准备上网的时候,发现网络没有正常连接. 刚刚开始怀疑的是,并没有连接上网络. 于是打开了终端,pin ...
- python ros 订阅robot_pose获取机器人位置
#!/usr/bin/env python import rospy import tf from tf.transformations import * from std_msgs.msg impo ...
- mysql处理时间戳
select name,telphone,FROM_UNIXTIME(add_time,'%Y-%m-%d %H:%i') as add_time from tf_apply_join order b ...
- Jaccard similarity(杰卡德相似度)和Abundance correlation(丰度相关性)
杰卡德距离(Jaccard Distance) 是用来衡量两个集合差异性的一种指标,它是杰卡德相似系数的补集,被定义为1减去Jaccard相似系数.而杰卡德相似系数(Jaccard similarit ...
- 20170813pptVBA批量插入图片
Sub AddSldIn() Dim Pre As Presentation Dim NewSld As Slide Set Pre = Application.ActivePresentation ...
- 4-14-17 JavaScript知识点总结(包括JOSN, ajax等,来源w3c)
JavaScript 也称 ECMAScript as "JavaScript" It is designed to run as a scripting language in ...
- Destroy the Colony CodeForces - 1111D (可逆背包,计数)
大意:给定字符串$s$, 保证长度为偶数, 给定q个询问, 每次询问给定两个位置$x$,$y$, 可以任意交换字符, 要求所有字符$s[x],s[y]$在同一半边, 剩余所有同种字符在同一半边的方案数 ...