답안 #66515

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
66515 2018-08-11T09:24:15 Z KLPP Turnir (COCI17_turnir) C++14
100 / 100
666 ms 28152 KB
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<stdio.h>

using namespace std;

int main(){
	int n;
	cin>>n;
	int pow=(1<<n);//cout<<pow<<endl;
	pair<int,int> arr[pow];
	for(int i=0;i<pow;i++){
		cin>>arr[i].first;
		arr[i].second=i;
	}
	sort(arr,arr+pow);
	int position=pow;
	int best[pow];
	best[arr[pow-1].second]=0;
	for(int i=pow-2;i>-1;i--){
		//cout<<arr[i].second<<endl;
		if(arr[i].first<arr[i+1].first){
			position=i+1;
		}
		for(int j=0;j<=n && position>=(1<<j);j++){
			//cout<<j<<endl;
			best[arr[i].second]=n-j;
			
		}
		//cout<<best[arr[i].second]<<endl;
	}
	for(int i=0;i<pow;i++)cout<<best[i]<<" ";
	cout<<endl;

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 480 KB Output is correct
3 Correct 4 ms 592 KB Output is correct
4 Correct 6 ms 776 KB Output is correct
5 Correct 21 ms 1240 KB Output is correct
6 Correct 44 ms 2088 KB Output is correct
7 Correct 84 ms 3688 KB Output is correct
8 Correct 167 ms 6864 KB Output is correct
9 Correct 330 ms 13912 KB Output is correct
10 Correct 666 ms 28152 KB Output is correct