0分!TLE
查看原帖
0分!TLE
1033544
pjr_freopen楼主2024/4/9 21:55

为什么超时?求助

#include<iostream>
#include<algorithm>
using namespace std;
int e[15];
struct node{
	int id;
	int wi,ci;
}a[20005];
inline int in(){//快速读入
	int x=1,y=0;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-')x=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		y=y*10+ch-'0';
		ch=getchar();
	}
	return x*y;
}
inline void out(int n){//快速输出
	if(n<0)putchar('-'),n*=-1;
	if(n>9)out(n/10);
	putchar (n%10+'0');
}
bool cmp1(node x,node y){
	x.wi>y.wi;
}
bool cmp2(node x,node y){
	if(x.wi==y.wi)return x.id<y.id;
	return x.wi>y.wi;
}
int main(){
	int n=in(),k=in();
	for(int i=1;i<=10;++i)e[i]=in();
	for(int i=1;i<=n;++i)a[i].wi=in(),a[i].id=i;
	sort(a+1,a+1+n,cmp1);
	for(int i=1;i<=n;++i)a[i].ci=(i-1)%10+1,a[i].wi=a[i].wi+e[a[i].ci];
	sort(a+1,a+1+n,cmp2);
	for(int i=1;i<=k;++i)out(a[i].id),printf(" ");
	return 0;
}

2024/4/9 21:55
加载中...