讨论 / C++ AC 保证对
潘崇明 2016-02-03 02:45:52
点我顶贴 收藏 删除
#include<iostream>

#include<algorithm>

using namespace std;

const int maxn = 50100;

struct People

{

int w, id;

bool operator < (const People& a) const

{

if(w == a.w) return id < a.id;

return w > a.w;

}

}A[maxn];

int n, k, E[11];

int main()

{

cin >> n >> k;

for(int i = 1; i <= 10; i++) cin >> E[i];

for(int i = 1; i <= n; i++)

{

cin >> A[i].w;

A[i].id = i;

}

sort(A+1, A+n+1);

for(int i = 1; i <= n; i++)

A[i].w += E[(i - 1) % 10 + 1];

sort(A+1, A+n+1);

for(int i = 1; i <= k; i++)

cout << A[i].id << (i == k ? '\n' : ' ');

return 0;

}

#1 Nightingalelyy@2016-10-16 05:15:11
回复 删除
其实我觉得c++库的sort挺不要脸的,但我就是喜欢。。。
#2 Magna_Medivh@2017-07-27 07:58:55
回复 删除
回复 #1 Nightingalelyy:And it's fast enough, with a small constant.
#3 yekechen5336@2021-05-22 22:33:55
回复 删除
yeah,I agree with his point.
#4 NemoArce@2021-06-23 20:07:37
回复 删除
回复 #1 Nightingalelyy:sort挺好用的,省得写快排
#5 undefined-moe@2021-06-29 20:50:53
回复 删除
!
#6 hs43lyc@2021-07-23 22:27:32
回复 删除
回复 #1 Nightingalelyy:我就是喜欢
查看更多回复
提交回复