답안 #97084

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
97084 2019-02-13T18:52:41 Z karlopuh Turnir (COCI17_turnir) C++14
30 / 100
3000 ms 19768 KB
#include <bits/stdc++.h>
using namespace std;

vector<int> niz;
vector<int> sorted;
vector<int> rj;
int n;
int N;

int main(){
	cin>>n;
	N=pow(2,n);
	for(int i=0;i<N;i++){
		int broj;
		cin>>broj;
		niz.push_back(broj);
		sorted.push_back(broj);
		rj.push_back(4);
	}
	
	sort(sorted.begin(),sorted.end());
	
	for(int i=0;i<N;i++){
		if(niz[i]==sorted[sorted.size()-1]){
			rj[i]=0;
		}
	}
	
	
	for(int b=0;b<N;b++){

		for(int i=1;i<=n;i++){
			bool moj=false;
			int treba=N/(pow(2,i))-1;
			for(int j=sorted.size()-1;j>=0;j--){
				if(sorted[j]<=niz[b] && moj){
					treba--;
				}
				if(!moj && sorted[j]<=niz[b])moj=true;
			}
			if(treba<=0){
				rj[b]=min(rj[b],i);
			}
		}	
	}			
	
	for(int i=0;i<N;i++){
		cout<<rj[i]<<" ";
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 512 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 11 ms 512 KB Output is correct
4 Incorrect 459 ms 512 KB Output isn't correct
5 Execution timed out 3014 ms 1024 KB Time limit exceeded
6 Execution timed out 3047 ms 1652 KB Time limit exceeded
7 Execution timed out 3063 ms 2792 KB Time limit exceeded
8 Execution timed out 3037 ms 4828 KB Time limit exceeded
9 Execution timed out 3044 ms 10252 KB Time limit exceeded
10 Execution timed out 3013 ms 19768 KB Time limit exceeded