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

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. JAVA爬虫对font-face字体反爬虫解密

    1.参考博客          https://www.jianshu.com/p/9975de57b0ce          https://blog.csdn.net/litang199612/a ...

  2. SSH 三大框架整合

    Spring整合web项目 在Servlet当中直接加载配置文件,获取对象 存在问题 每次请求都会创建一个Spring的工厂,这样浪费服务器资源,应该一个项目只有一个Spring的工厂. 在服务器启动 ...

  3. PHPStorm 快捷键大全(Win/Linux/Mac)

    下面的-符号记得改成 ‘`’,markdown 语法会转义.使用频率是我自己为准.仅供参考   Mac 符号 符号 解释 ⌘ Command ⇧ Shift ⌃ Control ↩ Enter/Ret ...

  4. OpenJudge计算概论-大象喝水

    /*========================================================= 大象喝水 总时间限制: 1000ms 内存限制: 65536kB 描述 一只大象 ...

  5. GIS 空间分析案例分析-错误排除经验总结

    GIS 空间分析案例分析-错误排除经验总结 商务科技合作:向日葵,135—4855__4328,xiexiaokui#qq.com 目录:问题发现,问题分析,解决方法,结果 1. problem di ...

  6. mac kafka 环境搭建 以及PHP的kafka扩展

    1.kafka安装 brew install kafka 安装会依赖zookeeper. 注意:安装目录:/usr/local/Cellar/kafka/0.10.2.0 2.安装的配置文件位置 /u ...

  7. 阶段5 3.微服务项目【学成在线】_day17 用户认证 Zuul_09-前端显示当前用户-需求分析

    登陆成功 应该要显示用户的信息 cookie只存了用户的身份令牌.不包含用户的信息 拿着短令牌 请求认证服务获取到jwt.然后存储到sessionStorage 1.用户请求认证服务,登录成功. 2. ...

  8. 查看linux是几位操作系统

    查看linux是几位操作系统 摘自:https://blog.csdn.net/a34569345/article/details/80179927 2018年05月03日 14:44:44 bill ...

  9. Java 8 Steam 例子整理

    Java 8 Steam 例子整理 kexue 关注 2016.06.06 17:44* 字数 1860 阅读 3901评论 0喜欢 6 IBM: Java 8 中的 Streams API 详解 为 ...

  10. Jmeter与BlazeMeter使用 录制导出jmx

    本文链接:https://blog.csdn.net/weixin_38250126/article/details/82629876JMeter 的脚本录制,除了自带的HTTP代理服务器以外,被大家 ...