60分TLE求助!
查看原帖
60分TLE求助!
554884
王轶楼主2023/3/23 22:02
#include<bits/stdc++.h>
#define ENDL putchar('\n')
#define ll long long
#define I inline
using namespace std;
I int read(){
	int f=1,x=0;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-')f=-f;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')x=x*10+ch-48,ch=getchar();
	return x*=f;
}
I void wt(int x){
	if(x<0)putchar('-'),x=-x;
	if(x>9)wt(x/10);
	putchar(x%10+48);
}
I void write1(int x){
	wt(x);
	ENDL;
}
I void write2(int x){
	wt(x);
	putchar(' ');
}
struct node{
	int x,num,id;
	bool operator <(const node a)const{
		return num==a.num?id<a.id:num>a.num;
	}
}a[10000010];
int n,r,q,k,g,maxn;
int main(){
    n=read(),r=read(),q=read();
    for(int i=0;i<n*2;i++){
        a[i].num=read();
        a[i].id=i;
    }
    for(int i=0;i<n*2;i++)a[i].x=read();
    while(stable_sort(a,a+n*2),r--)
		for(int i=0;i<2*n-1;i+=2)
			if(a[i].x>a[i+1].x)a[i].num++;
			else a[i+1].num++;
	stable_sort(a,a+n*2);
    write1(a[q-1].id+1);
    return 0;
}
2023/3/23 22:02
加载中...