【luogu1583】魔法照片 模拟

【luogu1583】魔法照片 模拟_第1张图片【luogu1583】魔法照片 模拟_第2张图片

#include
#include
#include
#include
#include
using namespace std;
struct node{int w,id;}a[2000010];
int e[2000010],n,m;
inline int read() {
    int ret=0;char ch=getchar();
    for (;!isdigit(ch);ch=getchar());
    for (;isdigit(ch);ch=getchar()) ret=ret*10+ch-'0';
 	return ret;
}
bool cmp(node x,node y){return x.w==y.w?x.idy.w;}
int main() {
    n=read();m=read();
    for (int i=1;i<=10;i++) e[i]=read();
    for (int i=1;i<=n;i++) a[i].w=read(),a[i].id=i;;
    sort(a+1,a+1+n,cmp);
    for (int i=1;i<=n;i++) a[i].w+=e[(i-1)%10+1];
    sort(a+1,a+1+n,cmp);
    printf("%d",a[1].id);
    for (int i=2;i<=m;i++) printf(" %d",a[i].id); 
    return 0;
}

 

你可能感兴趣的:(基本算法-模拟,luogu)