51,712
社区成员




把结构体换成两个数组就会超时
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;
struct Country{
int power;
int index;
}bicountry[138];
bool cmp(Country x,Country y)
{
return x.power < y.power;
}
int main()
{
int n;
int s = 0,t = 0;
cin >> n;
int cnt = pow(2,n);
for(int i = 1;i <= cnt;i++)
{
int aa;
cin >> aa;
bicountry[i].power = aa;
bicountry[i].index = i;
}
sort(bicountry+1,bicountry+cnt/2+1,cmp);
sort(bicountry+cnt/2+1,bicountry+cnt+1,cmp);
// for(int i = 1;i <= cnt;i++)
// cout << bicountry[i].power << " " << bicountry[i].index << endl;
if(bicountry[cnt/2].power > bicountry[cnt].power)
cout << bicountry[cnt].index;
else
cout << bicountry[cnt/2].index;
return 0;
}