codefroce 854 A.Fraction
题解:贪心,每次从能够出发的飞机中取一个最大的就好啦,用一个队列维护一下~
ac代码:
#include <cstdio>
#include <iostream>
#include <cstring>
#include <queue>
#include <vector>
#include <algorithm>
#include <stack>
#include <map>
using namespace std;
typedef long long ll;
struct node
{
ll v;
int id;
friend bool operator <(node a,node b)
{
return a.v < b.v;
}
}a[]; int tt[];
int main()
{
int n,m;
scanf("%d %d",&n,&m);
for(int i=;i<=n;i++)
{
scanf("%I64d",&a[i].v);
a[i].id=i;
}
ll ans=;
// cout<<"12"<<endl;
priority_queue<node> que;
int time=m;
for(int i=;i<=m;i++) que.push(a[i]);
// cout<<"123"<<endl;
while(!que.empty())
{
++time;
if(time <= n)que.push(a[time]);
node now=que.top();
que.pop();
int id=now.id;
tt[id]=time;// now time
ans+=(time-id)*a[id].v;
}
//cout<<"1234"<<endl;
printf("%I64d\n",ans);
printf("%d",tt[]);
for(int i=;i<=n;i++) printf(" %d",tt[i]);
cout<<endl;
return ;
}
codefroce 854 A.Fraction的更多相关文章
- Codeforce 854 A. Fraction
A. Fraction time limit per test 1 second memory limit per test 512 megabytes input standard input ou ...
- Codeforces Round #433 (Div. 2)【A、B、C、D题】
题目链接:Codeforces Round #433 (Div. 2) codeforces 854 A. Fraction[水] 题意:已知分子与分母的和,求分子小于分母的 最大的最简分数. #in ...
- [LeetCode] Fraction to Recurring Decimal 分数转循环小数
Given two integers representing the numerator and denominator of a fraction, return the fraction in ...
- Fraction to Recurring Decimal
Given two integers representing the numerator and denominator of a fraction, return the fraction in ...
- 【leetcode】Fraction to Recurring Decimal
Fraction to Recurring Decimal Given two integers representing the numerator and denominator of a fra ...
- Decimal To Fraction 小数转换成分数
以0.25为例, 0.25 * 100 = 25, 求25 和 100 的最大公约数gcd. 25/gcd 为分子. 100/gcd为分母. //小数转分数 //0.3 -> 3/10, 0.2 ...
- ✡ leetcode 166. Fraction to Recurring Decimal 分数转换 --------- java
Given two integers representing the numerator and denominator of a fraction, return the fraction in ...
- Leetcode 166. Fraction to Recurring Decimal 弗洛伊德判环
分数转小数,要求输出循环小数 如2 3 输出0.(6) 弗洛伊德判环的原理是在一个圈里,如果一个人的速度是另一个人的两倍,那个人就能追上另一个人.代码中one就是速度1的人,而two就是速度为2的人. ...
- [LeetCode] Fraction to Recurring Decimal 哈希表
Given two integers representing the numerator and denominator of a fraction, return the fraction in ...
随机推荐
- git 设置git用户名和邮箱,并生成秘钥
1.设置 git 用户名 aaron@ubuntu:~$ git config --global user.name "xxx" 2.设置 git 邮箱 aaron@ubuntu: ...
- git常见问题之git pull时Please specify which branch you want to merge with.
$ git pull时遇到如下提示 $ git pull warning: no common commits remote: Counting objects: 5, done. remote: C ...
- shell统计ip访问情况并分析访问日志
有日志 1.log,部分内容如下: 112.111.12.248 – [25/Sep/2013:16:08:31 +0800]formula-x.haotui.com“/seccode.php?upd ...
- ReentrantLock、Condition结合使用实现多线程通讯
package maptoxml; import java.util.concurrent.ExecutorService;import java.util.concurrent.Executors; ...
- SUBMIT标准程序取ALV数据
示例1: 调用J3RFLVMOBVEDH ,取物料的期初/ 期末庫存数.金额 FORM frm_call_j3rflvmobvedh. DATA: lr_bukrs TYPE RANGE OF buk ...
- Docker - 在CentOS7中安装Docker
在CentOS 7中安装Docker 1-确认系统信息 # cat /etc/redhat-release CentOS Linux release 7.2.1511 (Core) # uname - ...
- 海量无损高音质音乐文件分享180TB(持续更新)
海量无损高音质音乐文件分享180TBWAV,flac,ape格式(持续更新),由于本人是音乐发烧爱好者,收集海量的无损音乐,已经分类好了,比较方便查找,但是本地没法存储,所有放在网盘中,并且我这边还会 ...
- selenium3 web自动化测试框架 三:项目实战中PO模型的设计与封装
po模型设计思想 Page Object 模式主要是将每个页面设计为一个class,其中包含页面中的需要测试的元素(按钮,输入框,标题等),这样在Selenium测试页面中可以通过调取页面类来获取页面 ...
- 如何实现批量截取整个网页完整长截图,批量将网页保存成图片web2pic/webshot/screencapture/html2picture
如何实现批量截取整个网页完整长截图,批量将网页保存成图片web2pic/webshot/screencapture [困扰?疑问?]: 您是否正受到:如何将网页保存为图片的困扰?网页很高很长截图截不全 ...
- COLLATION 'latin1_swedish_ci' is not valid for CHARACTER SET 'utf8'
初始化 加上参数 --collation-server=utf8_general_ci 初始化 ./scripts/mysql_install_db --user=mysql --basedir=/u ...