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

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. Oracle 存储过程—为数传递变量

    oracle 存储过程的基本语法create or replace procedure proc1( p_para1 varchar2, p_para2 out varchar2, p_para3 i ...

  2. OpenJudge计算概论-数组逆序重放

    /*=============================================================== 数组逆序重放 总时间限制: 1000ms 内存限制: 65536kB ...

  3. https://en.wikipedia.org/wiki/Green_threads

    https://en.wikipedia.org/wiki/Green_threads

  4. eclipse手动添加本地jar包到本地maven仓库

    在使用maven进行构建项目时,有时候中央仓库不包含所需的jar包,就需要下载到本地后手动添加到本地仓库中.这里介绍下利用eclipse进行本地jar安装到maven本地仓库. 在Eclipse项目中 ...

  5. android 上下滑动标题栏和状态栏改变颜色实现

    import android.content.Context; import android.util.AttributeSet; import android.widget.ScrollView; ...

  6. 机器学习 - 算法 - SVM 支持向量机

    SVM 原理引入 支持向量机( SVM,Support Vector Machine ) 背景 2012年前较为火热, 但是在12年后被神经网络逼宫, 由于应用场景以及应用算法的不同, SVM还是需要 ...

  7. Qt自定义类重写 copy

    PtsData PtsData::copy(const PtsData &ptsData) { PtsData ptsData1; ptsData1.data_b = ptsData.data ...

  8. Flutter布局基本情况总结:

    1.一行内容,发布两边: 效果: Flex( direction: Axis.horizontal, children: <Widget>[ Expanded( flex: , child ...

  9. Javescript——数据类型

    原文链接:Understanding Data Types in JavaScript Data types are used to classify one particular type of d ...

  10. PAT 甲级1057 Stack (30 分)(不会,树状数组+二分)*****

    1057 Stack (30 分)   Stack is one of the most fundamental data structures, which is based on the prin ...