80分求助,#5WA
查看原帖
80分求助,#5WA
319478
zhibuba楼主2020/5/23 00:08
#include <stdio.h>
#include <string.h>

int L[128];
int R[64], S[64];

void comp(int n)
{
	for (int i = 0; i < n / 2; i++)
	{
		S[i] = (L[R[2 * i]] > L[R[2 * i + 1]] ? R[2 * i] : R[2 * i + 1]);
	}
	memcpy(R, S, sizeof(S));
	return ;	
}


int main(void)
{
	int t;
	scanf("%d", &t);
	int n = 1 << t; 
	for (int i = 0; i < n; i++)
		R[i] = i, scanf("%d", &L[i]);
	while (n > 2)
	{
		comp(n);
		n /= 2;
	}
	printf("%d", (L[R[0]] < L[R[1]] ? R[0] : R[1]) + 1);
	return 0;
}
2020/5/23 00:08
加载中...