제출 #1287346

#제출 시각아이디문제언어결과실행 시간메모리
1287346kerem라멘 (JOI14_ramen)C++20
100 / 100
1 ms348 KiB
#include "ramen.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back

int calc(vector<int> v,int t){
	vector<int> tmp;
	while(v.size()>1){
		int n=v.size();
		for(int i=1;i<n;i+=2){
			if(Compare(v[i-1],v[i])==t)
				tmp.pb(v[i-1]);
			else tmp.pb(v[i]);
		}
		if(n&1) tmp.pb(v.back());
		swap(v,tmp);
		tmp.clear();
	}
	return v[0];
}
void Ramen(int N) {
	if(N==1) Answer(0,0);
	
	vector<int> a,b;
	for(int i=1;i<N;i+=2){
		if(Compare(i-1,i)>0){
			a.pb(i);b.pb(i-1);
		}
		else{
			a.pb(i-1),b.pb(i);
		}
	}
	if(N&1){
		a.pb(N-1);
		b.pb(N-1);
	}
	int x=calc(a,-1);
	int y=calc(b,1);
	//~ cout << x << " " << y << "\n";
	Answer(x,y);
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...