只过了样例,求问
查看原帖
只过了样例,求问
301765
ElfOfEra楼主2021/10/4 17:17
// Problem: P1583 魔法照片
// Contest: Luogu
// URL: https://www.luogu.com.cn/problem/P1583
// Memory Limit: 125 MB
// Time Limit: 1000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include<iostream>
using namespace std;
int main(){
	int n,k,e[11],w[20001],wc[20001];
	cin>>n>>k;
	
	//加权参数赋值
	for(int i=1;i<=10;i++){
		cin>>e[i];	
	}
	
	//权重赋值
	for(int i=1;i<=n;i++){
		cin>>w[i];
	}
	
	//数组复制
	for(int i=1;i<=n;i++){
		wc[i]=w[i];
	}
	
	//初始权值排序
	int d[20001];
	for(int i=1;i<=n;i++){
		int maxx=0,maxn=0;
		for(int l=1;l<=20000;l++){
			if(wc[l]>maxx){
				maxx=wc[l];
				maxn=l;
			}
		}
		wc[maxn]=0;
		d[i]=maxn;
	}
	
	//加权
	for(int i=1;i<=n;i++){
		w[i]+=e[((d[i])%10)+1];
	}
	
	//二次数组复制
	for(int i=1;i<=n;i++){
		wc[i]=w[i];
	}
	
	//输出最大权的k个人
	for(int i=1;i<=k;i++){
		int maxx=0,maxn=0;
		for(int l=1;l<=20000;l++){
			if(wc[l]>maxx){
				maxx=wc[l];
				maxn=l;
			}
		}
		wc[maxn]=0;
		cout<<maxn;
		if(i!=k){
			cout<<" ";
		}
	}
	cout<<endl;
	
	return 0;
}
2021/10/4 17:17
加载中...