题解:贪心,每次从能够出发的飞机中取一个最大的就好啦,用一个队列维护一下~

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的更多相关文章

  1. Codeforce 854 A. Fraction

    A. Fraction time limit per test 1 second memory limit per test 512 megabytes input standard input ou ...

  2. Codeforces Round #433 (Div. 2)【A、B、C、D题】

    题目链接:Codeforces Round #433 (Div. 2) codeforces 854 A. Fraction[水] 题意:已知分子与分母的和,求分子小于分母的 最大的最简分数. #in ...

  3. [LeetCode] Fraction to Recurring Decimal 分数转循环小数

    Given two integers representing the numerator and denominator of a fraction, return the fraction in ...

  4. Fraction to Recurring Decimal

    Given two integers representing the numerator and denominator of a fraction, return the fraction in ...

  5. 【leetcode】Fraction to Recurring Decimal

    Fraction to Recurring Decimal Given two integers representing the numerator and denominator of a fra ...

  6. Decimal To Fraction 小数转换成分数

    以0.25为例, 0.25 * 100 = 25, 求25 和 100 的最大公约数gcd. 25/gcd 为分子. 100/gcd为分母. //小数转分数 //0.3 -> 3/10, 0.2 ...

  7. ✡ leetcode 166. Fraction to Recurring Decimal 分数转换 --------- java

    Given two integers representing the numerator and denominator of a fraction, return the fraction in ...

  8. Leetcode 166. Fraction to Recurring Decimal 弗洛伊德判环

    分数转小数,要求输出循环小数 如2 3 输出0.(6) 弗洛伊德判环的原理是在一个圈里,如果一个人的速度是另一个人的两倍,那个人就能追上另一个人.代码中one就是速度1的人,而two就是速度为2的人. ...

  9. [LeetCode] Fraction to Recurring Decimal 哈希表

    Given two integers representing the numerator and denominator of a fraction, return the fraction in ...

随机推荐

  1. 服务端 CORS 解决跨域

    当协议.域名.端口中任一个不同时产生跨域 CORS 跨域资源共享(Cross-origin resource sharing) 参考资料https://developer.mozilla.org/zh ...

  2. javascript创建对象的几种方式?

    javascript创建对象简单的说,无非就是使用内置对象或各种自定义对象,当然还可以用JSON:但写法有很多种,也能混合使用. 1.对象字面量的方式 person={ firstname:" ...

  3. Android插件化(六): OpenAtlasの改写aapt以防止资源ID冲突

    Android插件化(六): OpenAtlasの改写aapt以防止资源ID冲突 转 https://www.300168.com/yidong/show-2791.html   核心提示:引言And ...

  4. 18Flutter中的路由、路由替换、返回到根路由:

    路由: 正常跳转: Navigator.pushNamed(context,'/product');   路由替换: Navigator.pushReplacementNamed(context, ' ...

  5. rm -rf 误删后该怎么办?

    Google有一个开源的包 叫ext3grep工具他可以回复删除的文件,甚至是drop database,想什么呢,数据库啦!这个工具需要在ext3或者ext4 的文件系统上才可以实现,因为ext3文 ...

  6. Js 实现局部打印功能

    1.当前页面 var bodyHtml = window.document.body.innerHTML; window.document.body.innerHTML = printHtml;//p ...

  7. SQLite 的简单使用

    程序运行结果如下 : 输入name和age,点击"确认插入"按钮,即插入一条记录到数据库. 程序代码如下:(有详细注释,相信大家都看得懂哈!!!) ////  ViewContro ...

  8. html的css背景图的repeat

    HTML里background-image中,可以设置background-repeat实现平铺,前面博文中关于css样式换行的(相关博文:超文本css样式换行),其中有个三个div组合的,中间的di ...

  9. iOS技术面试06:应用程序

    1.NSRunLoop的实现机制,及在多线程中如何使用 NSRunLoop是IOS消息机制的处理模式 >1.NSRunLoop的主要作用:控制NSRunLoop里面线程的执行和休眠,在有事情做的 ...

  10. 《Django企业开发实战 高效Python Web框架指南》胡阳

    链接:https://pan.baidu.com/s/1NmN_IT5RvevCMt9bZCW1-g提取码:2ki9