QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#285280#7939. High Towersucup-team087#AC ✓134ms171732kbC++2013.2kb2023-12-16 17:41:162023-12-16 17:41:17

Judging History

你现在查看的是最新测评结果

  • [2023-12-16 17:41:17]
  • 评测
  • 测评结果:AC
  • 用时:134ms
  • 内存:171732kb
  • [2023-12-16 17:41:16]
  • 提交

answer

#ifndef LOCAL
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#endif

#include <bits/stdc++.h>
using namespace std;

using ll=long long;
//#define int ll

#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define si(x) int(x.size())
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif

template<class t,class u> bool chmax(t&a,u b){if(a<b){a=b;return true;}else return false;}
template<class t,class u> bool chmin(t&a,u b){if(b<a){a=b;return true;}else return false;}

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class t,class u>
ostream& operator<<(ostream& os,const pair<t,u>& p){
	return os<<"{"<<p.a<<","<<p.b<<"}";
}

template<class t> ostream& operator<<(ostream& os,const vc<t>& v){
	os<<"{";
	for(auto e:v)os<<e<<",";
	return os<<"}";
}

#define mp make_pair
#define mt make_tuple
#define one(x) memset(x,-1,sizeof(x))
#define zero(x) memset(x,0,sizeof(x))
#ifdef LOCAL
void dmpr(ostream&os){os<<endl;}
template<class T,class... Args>
void dmpr(ostream&os,const T&t,const Args&... args){
	os<<t<<" ";
	dmpr(os,args...);
}
#define dmp2(...) dmpr(cerr,__LINE__,##__VA_ARGS__)
#else
#define dmp2(...) void(0)
#endif

using uint=unsigned;
using ull=unsigned long long;

template<class t,size_t n>
ostream& operator<<(ostream&os,const array<t,n>&a){
	return os<<vc<t>(all(a));
}

template<int i,class T>
void print_tuple(ostream&,const T&){
}

template<int i,class T,class H,class ...Args>
void print_tuple(ostream&os,const T&t){
	if(i)os<<",";
	os<<get<i>(t);
	print_tuple<i+1,T,Args...>(os,t);
}

template<class ...Args>
ostream& operator<<(ostream&os,const tuple<Args...>&t){
	os<<"{";
	print_tuple<0,tuple<Args...>,Args...>(os,t);
	return os<<"}";
}

ll read(){
	ll i;
	cin>>i;
	return i;
}

vi readvi(int n,int off=0){
	vi v(n);
	rep(i,n)v[i]=read()+off;
	return v;
}

pi readpi(int off=0){
	int a,b;cin>>a>>b;
	return pi(a+off,b+off);
}

template<class t>
void print_single(t x,int suc=1){
	cout<<x;
	if(suc==1)
		cout<<"\n";
	if(suc==2)
		cout<<" ";
}

template<class t,class u>
void print_single(const pair<t,u>&p,int suc=1){
	print_single(p.a,2);
	print_single(p.b,suc);
}

template<class T>
void print_single(const vector<T>&v,int suc=1){
	rep(i,v.size())
		print_single(v[i],i==int(v.size())-1?suc:2);
}

template<class T>
void print_offset(const vector<T>&v,ll off,int suc=1){
	rep(i,v.size())
		print_single(v[i]+off,i==int(v.size())-1?suc:2);
}

template<class T,size_t N>
void print_single(const array<T,N>&v,int suc=1){
	rep(i,N)
		print_single(v[i],i==int(N)-1?suc:2);
}

template<class T>
void print(const T&t){
	print_single(t);
}

template<class T,class ...Args>
void print(const T&t,const Args&...args){
	print_single(t,2);
	print(args...);
}

string readString(){
	string s;
	cin>>s;
	return s;
}

template<class T>
T sq(const T& t){
	return t*t;
}

void YES(bool ex=true){
	cout<<"YES\n";
	if(ex)exit(0);
	#ifdef LOCAL
	cout.flush();
	#endif
}
void NO(bool ex=true){
	cout<<"NO\n";
	if(ex)exit(0);
	#ifdef LOCAL
	cout.flush();
	#endif
}
void Yes(bool ex=true){
	cout<<"Yes\n";
	if(ex)exit(0);
	#ifdef LOCAL
	cout.flush();
	#endif
}
void No(bool ex=true){
	cout<<"No\n";
	if(ex)exit(0);
	#ifdef LOCAL
	cout.flush();
	#endif
}
//#define CAPITAL
/*
void yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<"\n";
	#else
	cout<<"Yes"<<"\n";
	#endif
	if(ex)exit(0);
	#ifdef LOCAL
	cout.flush();
	#endif
}
void no(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<"\n";
	#else
	cout<<"No"<<"\n";
	#endif
	if(ex)exit(0);
	#ifdef LOCAL
	cout.flush();
	#endif
}*/
void possible(bool ex=true){
	#ifdef CAPITAL
	cout<<"POSSIBLE"<<"\n";
	#else
	cout<<"Possible"<<"\n";
	#endif
	if(ex)exit(0);
	#ifdef LOCAL
	cout.flush();
	#endif
}
void impossible(bool ex=true){
	#ifdef CAPITAL
	cout<<"IMPOSSIBLE"<<"\n";
	#else
	cout<<"Impossible"<<"\n";
	#endif
	if(ex)exit(0);
	#ifdef LOCAL
	cout.flush();
	#endif
}

constexpr ll ten(int n){
	return n==0?1:ten(n-1)*10;
}

const ll infLL=LLONG_MAX/3;

#ifdef int
const int inf=infLL;
#else
const int inf=INT_MAX/2-100;
#endif

int topbit(signed t){
	return t==0?-1:31-__builtin_clz(t);
}
int topbit(ll t){
	return t==0?-1:63-__builtin_clzll(t);
}
int topbit(ull t){
	return t==0?-1:63-__builtin_clzll(t);
}
int botbit(signed a){
	return a==0?32:__builtin_ctz(a);
}
int botbit(ll a){
	return a==0?64:__builtin_ctzll(a);
}
int botbit(ull a){
	return a==0?64:__builtin_ctzll(a);
}
int popcount(signed t){
	return __builtin_popcount(t);
}
int popcount(ll t){
	return __builtin_popcountll(t);
}
int popcount(ull t){
	return __builtin_popcountll(t);
}
int bitparity(ll t){
	return __builtin_parityll(t);
}
bool ispow2(int i){
	return i&&(i&-i)==i;
}
ll mask(int i){
	return (ll(1)<<i)-1;
}
ull umask(int i){
	return (ull(1)<<i)-1;
}
ll minp2(ll n){
	if(n<=1)return 1;
	else return ll(1)<<(topbit(n-1)+1);
}

bool inc(int a,int b,int c){
	return a<=b&&b<=c;
}

template<class t> void mkuni(vc<t>&v){
	sort(all(v));
	v.erase(unique(all(v)),v.ed);
}

ll rand_int(ll l, ll r) { //[l, r]
	//#ifdef LOCAL
	static mt19937_64 gen;
	/*#else
	static mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count());
	#endif*/
	return uniform_int_distribution<ll>(l, r)(gen);
}

ll rand_int(ll k){ //[0,k)
	return rand_int(0,k-1);
}

template<class t>
void myshuffle(vc<t>&a){
	rep(i,si(a))swap(a[i],a[rand_int(0,i)]);
}

template<class t,class u>
int lwb(const vc<t>&v,const u&a){
	return lower_bound(all(v),a)-v.bg;
}
template<class t,class u>
bool bis(const vc<t>&v,const u&a){
	return binary_search(all(v),a);
}

vvc<int> readGraph(int n,int m){
	vvc<int> g(n);
	rep(i,m){
		int a,b;
		cin>>a>>b;
		//sc.read(a,b);
		a--;b--;
		g[a].pb(b);
		g[b].pb(a);
	}
	return g;
}

vvc<int> readTree(int n){
	return readGraph(n,n-1);
}

template<class t>
vc<t> presum(const vc<t>&a){
	vc<t> s(si(a)+1);
	rep(i,si(a))s[i+1]=s[i]+a[i];
	return s;
}
vc<ll> presum(const vi&a){
	vc<ll> s(si(a)+1);
	rep(i,si(a))s[i+1]=s[i]+a[i];
	return s;
}
//BIT で数列を管理するときに使う (CF850C)
template<class t>
vc<t> predif(vc<t> a){
	gnr(i,1,si(a))a[i]-=a[i-1];
	return a;
}
template<class t>
vvc<ll> imos(const vvc<t>&a){
	int n=si(a),m=si(a[0]);
	vvc<ll> b(n+1,vc<ll>(m+1));
	rep(i,n)rep(j,m)
		b[i+1][j+1]=b[i+1][j]+b[i][j+1]-b[i][j]+a[i][j];
	return b;
}

//verify してないや
void transvvc(int&n,int&m){
	swap(n,m);
}
template<class t,class... Args>
void transvvc(int&n,int&m,vvc<t>&a,Args&...args){
	assert(si(a)==n);
	vvc<t> b(m,vi(n));
	rep(i,n){
		assert(si(a[i])==m);
		rep(j,m)b[j][i]=a[i][j];
	}
	a.swap(b);
	transvvc(n,m,args...);
}
//CF854E
void rotvvc(int&n,int&m){
	swap(n,m);
}
template<class t,class... Args>
void rotvvc(int&n,int&m,vvc<t>&a,Args&...args){
	assert(si(a)==n);
	vvc<t> b(m,vi(n));
	rep(i,n){
		assert(si(a[i])==m);
		rep(j,m)b[m-1-j][i]=a[i][j];
	}
	a.swap(b);
	rotvvc(n,m,args...);
}

//ソートして i 番目が idx[i]
//CF850C
template<class t>
vi sortidx(const vc<t>&a){
	int n=si(a);
	vi idx(n);iota(all(idx),0);
	sort(all(idx),[&](int i,int j){return a[i]<a[j];});
	return idx;
}
//vs[i]=a[idx[i]]
//例えば sortidx で得た idx を使えば単にソート列になって返ってくる
//CF850C
template<class t>
vc<t> a_idx(const vc<t>&a,const vi&idx){
	int n=si(a);
	assert(si(idx)==n);
	vc<t> vs(n);
	rep(i,n)vs[i]=a[idx[i]];
	return vs;
}
//CF850C
vi invperm(const vi&p){
	int n=si(p);
	vi q(n);
	rep(i,n)q[p[i]]=i;
	return q;
}

template<class t,class s=t>
s SUM(const vc<t>&a){
	return accumulate(all(a),s(0));
}

template<class t>
t MAX(const vc<t>&a){
	return *max_element(all(a));
}

template<class t>
pair<t,int> MAXi(const vc<t>&a){
	auto itr=max_element(all(a));
	return mp(*itr,itr-a.bg);
}

template<class t>
t MIN(const vc<t>&a){
	return *min_element(all(a));
}

template<class t>
pair<t,int> MINi(const vc<t>&a){
	auto itr=min_element(all(a));
	return mp(*itr,itr-a.bg);
}

vi vid(int n){
	vi res(n);iota(all(res),0);
	return res;
}

template<class S>
void soin(S&s){
	sort(all(s));
}

template<class S,class F>
void soin(S&s,F&&f){
	sort(all(s),forward<F>(f));
}

template<class S>
S soout(S s){
	soin(s);
	return s;
}

template<class S>
void rein(S&s){
	reverse(all(s));
}

template<class S>
S reout(S s){
	rein(s);
	return s;
}

template<class t,class u>
pair<t,u>&operator+=(pair<t,u>&a,pair<t,u> b){
	a.a+=b.a;a.b+=b.b;return a;}
template<class t,class u>
pair<t,u>&operator-=(pair<t,u>&a,pair<t,u> b){
	a.a-=b.a;a.b-=b.b;return a;}
template<class t,class u>
pair<t,u> operator+(pair<t,u> a,pair<t,u> b){return mp(a.a+b.a,a.b+b.b);}
template<class t,class u>
pair<t,u> operator-(pair<t,u> a,pair<t,u> b){return mp(a.a-b.a,a.b-b.b);}

template<class t>
t gpp(vc<t>&vs){
	assert(si(vs));
	t res=move(vs.back());
	vs.pop_back();
	return res;
}

template<class t,class u>
void pb(vc<t>&a,const vc<u>&b){
	a.insert(a.ed,all(b));
}

template<class t,class...Args>
vc<t> cat(vc<t> a,Args&&...b){
	(pb(a,forward<Args>(b)),...);
	return a;
}

template<class t,class u>
vc<t>& operator+=(vc<t>&a,u x){
	for(auto&v:a)v+=x;
	return a;
}

template<class t,class u>
vc<t> operator+(vc<t> a,u x){
	return a+=x;
}

template<class t,class u>
vc<t>& operator-=(vc<t>&a,u x){
	for(auto&v:a)v-=x;
	return a;
}

template<class t,class u>
vc<t>& operator-(vc<t> a,u x){
	return a-=x;
}

template<class t,class u>
void remval(vc<t>&a,const u&v){
	a.erase(remove(all(a),v),a.ed);
}

template<class t,class u>
void fila(vc<t>&vs,const u&a){
	fill(all(vs),a);
}

template<class t,class u>
int findid(const vc<t>&vs,const u&a){
	auto itr=find(all(vs),a);
	if(itr==vs.ed)return -1;
	else return itr-vs.bg;
}

template<class t>
void rtt(vc<t>&vs,int i){
	rotate(vs.bg,vs.bg+i,vs.ed);
}

//VERIFY: yosupo
//AOJGRL5C
template<class t,class u>
struct sparsetable{
	vvc<t> a;
	u f;
	const t id;
	sparsetable(const vc<t>& d,u ff,t w):f(ff),id(w){
		if(d.empty())return;
		int n=d.size(),h=topbit(n);
		a.resize(h+1);
		a[0]=d;
		rng(j,1,h+1){
			a[j].resize(n-(1<<j)+1);
			rep(i,n-(1<<j)+1)
				a[j][i]=f(a[j-1][i],a[j-1][i+(1<<(j-1))]);
		}
	}
	t get(int b,int e){
		assert(b<=e);
		if(b==e)return id;
		int d=topbit(e-b);
		return f(a[d][b],a[d][e-(1<<d)]);
	}
};
const auto pimax=[](pi a,pi b){
	return max(a,b);
};
using maxst=sparsetable<pi,decltype(pimax)>;

bool dbg=false;

vi fast(vi a){
	int n=si(a);
	vc<pi> ai(n);
	rep(i,n)ai[i]=pi(a[i],i);
	maxst st(ai,pimax,pi(-1,-1));
	vi h(n,-1);
	auto dfs=[&](auto self,int l,int r,int d,int off)->bool{
		if(l+1==r)return true;
		dmp2(l,r,d,off);
		vi ls;
		auto work=[&]()->bool{
			if(!self(self,l,ls.back(),d+1,off+1))return false;
			if(!self(self,ls.front(),r,d+1,off+1))return false;
			rep(i,si(ls)-1){
				if(!self(self,ls[i+1],ls[i],d+1,off+2))return false;
			}
			for(auto i:ls)h[i]=d;
			return true;
		};
		{
			if(a[l+1]-off==r-l-2){
				ls.clear();
				ls.pb(l+1);
				if(work())return true;
			}
			if(a[r-1]-off==r-l-2){
				ls.clear();
				ls.pb(r-1);
				if(work())return true;
			}
		}
		int x=l;
		while(x+1<r){
			/*if(!(x+1<r)){
				cerr<<a<<endl;
			}
			assert(x+1<r);*/
			x=st.get(x+1,r).b;
			
			bool ok=true;
			int pre=r-1,cur=x;
			ls.clear();
			while(1){
				ls.pb(cur);
				int u=a[cur]-off-(pre-cur);
				if(u<0){
					ok=false;
					break;
				}
				int nx=cur-u;
				if(nx<=l){
					ok=false;
					break;
				}
				if(nx<cur&&st.get(nx+1,cur).a-off>cur-nx){
					ok=false;
					break;
				}
				if(nx==l+1){
					if(nx<cur&&a[nx]-off>cur-nx){
						ok=false;
					}
					break;
				}
				if(nx==cur){
					ok=false;
					break;
				}
				pre=cur;
				cur=nx;
			}
			if(ok){
				dmp(ls);
				if(work())return true;
			}
		}
		return false;
	};
	dfs(dfs,-1,n,0,0);
	const int V=ten(9);
	//dmp(h);
	rep(i,n)h[i]=V-h[i];
	return h;
}

vi original(vi a){
	int n=si(a);
	vi res(n);
	rep(i,n){
		int mid=-inf;
		rng(j,i+1,n){
			if(max(a[i],a[j])>mid){
				res[i]++;
				res[j]++;
			}
			chmax(mid,a[j]);
		}
	}
	return res;
}

void slv(){
	int n;cin>>n;
	vi a=readvi(n);
	print(fast(a));
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);
	/*
	fast({1,2,3,2,3,2,1});
	fast({2,2,3,2,1});
	fast({3,2,3,2});
	auto check=[&](vi h){
		vi a=original(h);
		dmp(a);
		vi ans=fast(a);
		vi b=original(ans);
		assert(a==b);
	};
	//check(vi(4,0));
	
	rng(n,1,11){
		rng(vmax,1,11){
			cerr<<"N "<<n<<" Vmax "<<vmax<<endl;
			rep(itr,10000){
				vi h(n);
				rep(i,n)h[i]=rand_int(vmax);
				
				check(h);
			}
		}
	}*/
	
	if(dbg){
		while(1)slv();
	}else{
		//int t;cin>>t;rep(_,t)
		slv();
	}
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3568kb

input:

6
3 3 4 2 5 1

output:

999999998 999999997 999999999 999999998 1000000000 999999999

result:

ok 

Test #2:

score: 0
Accepted
time: 1ms
memory: 3452kb

input:

4
3 3 3 3

output:

1000000000 999999999 999999998 999999997

result:

ok 

Test #3:

score: 0
Accepted
time: 54ms
memory: 44004kb

input:

264668
5 5 5 5 9 5 5 5 7 3 5 3 11 9 9 9 8 9 8 9 12 4 4 9 5 5 6 4 12 4 7 5 6 5 18 12 6 12 11 11 11 11 11 11 12 19 5 5 8 6 6 6 26 7 7 7 8 6 7 6 6 12 10 6 9 8 8 8 10 4 22 4 4 6 3 6 4 4 8 5 5 5 7 3 8 6 6 6 6 8 3 5 3 6 4 4 8 5 5 5 10 6 6 6 6 17 4 12 5 11 6 10 7 9 8 8 16 5 5 5 8 4 4 12 8 7 7 8 6 9 4 14 5 ...

output:

999999998 999999997 999999996 999999995 999999999 999999998 999999997 999999996 999999999 999999998 999999999 999999998 999999999 999999998 999999997 999999996 999999993 999999994 999999993 999999995 999999999 999999998 999999997 999999999 999999997 999999996 999999998 999999997 999999999 999999997 ...

result:

ok 

Test #4:

score: 0
Accepted
time: 66ms
memory: 68524kb

input:

409115
2 4 3 7 4 5 4 7 3 6 4 4 7 4 4 6 3 11 6 6 6 9 6 6 6 11 3 10 8 5 8 7 7 7 10 3 5 3 8 6 6 6 6 8 3 8 6 6 6 6 10 5 5 5 8 4 4 8 4 5 4 7 3 5 3 6 4 4 8 5 5 5 9 4 5 4 8 4 4 7 4 4 8 5 5 5 8 4 4 7 4 4 6 3 9 4 7 6 6 6 9 3 6 4 4 28 7 7 7 12 8 8 9 7 12 7 7 12 8 8 9 7 9 24 7 7 7 8 4 34 8 8 8 8 8 10 5 5 13 4 ...

output:

999999998 999999999 999999998 999999999 999999997 999999998 999999997 999999999 999999998 999999999 999999998 999999997 999999999 999999998 999999997 999999999 999999998 999999999 999999997 999999996 999999995 999999998 999999997 999999996 999999995 999999999 999999998 999999999 999999998 999999996 ...

result:

ok 

Test #5:

score: 0
Accepted
time: 63ms
memory: 72044kb

input:

430320
2 5 4 4 8 5 5 5 18 7 7 7 9 6 7 5 14 5 7 6 6 18 4 5 4 14 6 6 6 10 7 7 7 7 31 4 12 7 7 10 8 8 9 6 13 5 7 5 7 5 7 5 7 5 5 28 5 6 5 7 4 12 6 6 6 6 13 4 8 6 6 7 5 11 4 4 7 4 4 6 3 7 5 5 5 10 4 6 5 5 9 4 4 8 5 5 5 7 3 6 4 4 8 5 5 5 15 7 7 8 6 8 11 6 6 6 18 5 5 8 6 6 6 11 4 4 6 3 27 12 8 8 8 9 8 7 8...

output:

999999998 999999999 999999998 999999997 999999999 999999998 999999997 999999996 999999999 999999996 999999995 999999994 999999997 999999996 999999997 999999996 999999998 999999996 999999997 999999996 999999995 999999999 999999997 999999998 999999997 999999999 999999997 999999996 999999995 999999998 ...

result:

ok 

Test #6:

score: 0
Accepted
time: 88ms
memory: 74140kb

input:

445524
4 4 6 4 4 32 6 6 6 10 7 7 7 21 7 10 9 9 9 11 10 9 9 9 11 7 7 20 5 6 5 45 8 11 10 10 10 11 13 7 7 14 7 6 6 19 5 6 5 35 6 6 6 11 8 7 8 7 9 9 7 7 7 8 5 19 3 5 3 17 5 7 6 6 15 6 6 11 6 9 8 8 8 64 6 6 7 5 12 8 8 8 8 12 7 7 7 11 6 7 6 10 6 6 10 7 7 7 17 13 13 13 13 11 13 12 12 13 19 6 9 7 8 7 15 9 ...

output:

999999997 999999996 999999998 999999997 999999996 999999999 999999997 999999996 999999995 999999998 999999997 999999996 999999995 999999998 999999995 999999996 999999995 999999994 999999993 999999997 999999997 999999996 999999995 999999994 999999997 999999996 999999995 999999998 999999996 999999997 ...

result:

ok 

Test #7:

score: 0
Accepted
time: 89ms
memory: 80260kb

input:

481648
4 4 13 8 10 9 9 11 7 11 11 11 74 4 13 8 8 8 12 9 9 9 9 13 48 28 18 11 11 18 13 14 13 14 16 12 12 28 16 14 14 14 16 13 13 16 17 9 30 7 24 16 11 11 16 14 14 14 14 14 18 9 10 11 10 10 10 22 49 5 7 5 5 69 4 8 6 7 6 7 21 8 8 8 9 9 8 8 8 12 14 5 5 17 4 4 19 5 6 5 10 7 7 7 13 9 8 8 8 9 6 131 10 10 1...

output:

999999997 999999996 999999998 999999992 999999993 999999992 999999991 999999994 999999993 999999995 999999996 999999997 999999999 999999997 999999998 999999996 999999995 999999994 999999997 999999996 999999995 999999994 999999993 999999998 999999998 999999996 999999994 999999992 999999991 999999993 ...

result:

ok 

Test #8:

score: 0
Accepted
time: 83ms
memory: 70112kb

input:

421202
5 5 7 5 5 10 4 5 4 43 5 16 13 10 10 13 11 11 11 13 15 7 7 34 11 9 9 11 9 9 12 6 14 6 13 6 11 7 10 9 9 9 71 8 8 8 8 13 8 8 9 7 12 7 7 13 8 9 8 10 7 16 10 9 10 9 10 10 31 6 6 12 9 9 9 9 9 10 4 68 7 7 7 8 13 6 12 7 11 8 10 9 9 31 6 9 8 8 8 12 7 7 10 7 7 10 7 7 7 36 4 6 5 5 34 5 6 5 29 9 9 9 9 9 ...

output:

999999996 999999995 999999997 999999996 999999995 999999998 999999996 999999997 999999996 999999999 999999996 999999997 999999995 999999992 999999991 999999993 999999992 999999991 999999990 999999994 999999996 999999995 999999994 999999998 999999995 999999993 999999992 999999994 999999993 999999992 ...

result:

ok 

Test #9:

score: 0
Accepted
time: 87ms
memory: 80160kb

input:

480658
15 8 8 8 10 7 7 15 8 8 9 7 9 16 3 40 5 5 9 7 7 7 15 11 9 11 10 10 11 11 14 6 6 11 7 7 7 8 5 27 3 11 6 7 6 7 9 5 5 13 4 5 4 8 4 4 6 3 10 5 8 7 7 7 8 18 9 7 7 9 7 7 11 5 5 27 7 7 7 7 12 8 8 8 8 13 7 7 7 8 5 43 5 5 8 6 6 24 9 10 9 11 8 12 7 17 8 10 9 9 14 9 9 9 9 22 4 42 5 5 16 11 8 10 9 10 8 12...

output:

999999997 999999994 999999993 999999992 999999995 999999994 999999993 999999996 999999993 999999992 999999994 999999993 999999995 999999998 999999997 999999999 999999997 999999996 999999998 999999997 999999996 999999995 999999998 999999997 999999993 999999994 999999993 999999992 999999995 999999996 ...

result:

ok 

Test #10:

score: 0
Accepted
time: 73ms
memory: 71288kb

input:

430417
5 5 5 27 7 7 7 11 8 7 8 7 24 8 8 12 8 10 9 9 16 8 9 8 9 16 34 4 5 4 8 5 5 5 430416 5 5 8 5 6 5 17 6 6 6 11 5 8 6 7 6 18 73 6 8 7 7 33 9 9 11 9 9 15 8 10 9 9 29 10 10 13 10 11 10 17 11 11 11 11 19 8 8 72 8 12 11 10 11 10 12 24 10 11 10 16 12 12 12 13 10 17 8 17 42 8 9 8 11 8 8 22 9 9 12 10 10 ...

output:

999999997 999999996 999999995 999999998 999999995 999999994 999999993 999999996 999999995 999999993 999999994 999999993 999999997 999999993 999999992 999999994 999999992 999999993 999999992 999999991 999999995 999999992 999999993 999999992 999999994 999999996 999999999 999999996 999999997 999999996 ...

result:

ok 

Test #11:

score: 0
Accepted
time: 93ms
memory: 79720kb

input:

480452
5 9 8 8 8 8 9 13 5 6 5 6 22 9 7 9 8 8 9 9 10 3 480451 5 5 8 6 6 6 10 4 4 31 6 7 6 7 22 7 9 8 8 15 10 9 10 9 11 7 18 7 7 7 231 10 10 10 10 11 7 30 9 14 13 11 13 12 12 15 8 24 11 11 11 12 9 15 10 10 10 40 13 10 10 13 11 11 11 13 14 6 41 9 7 7 8 6 113 12 15 14 14 14 15 16 10 37 23 15 15 15 21 15...

output:

999999995 999999996 999999995 999999994 999999993 999999992 999999997 999999998 999999995 999999996 999999995 999999997 999999999 999999997 999999993 999999994 999999993 999999992 999999995 999999996 999999998 999999997 1000000000 999999996 999999995 999999997 999999996 999999995 999999994 999999998...

result:

ok 

Test #12:

score: 0
Accepted
time: 81ms
memory: 74412kb

input:

448826
6 6 6 10 7 7 7 7 26 8 8 8 15 8 10 9 9 12 8 8 16 5 18 5 5 28 3 3 52 5 6 5 17 6 8 7 7 14 6 10 8 8 9 7 24 5 5 9 5 7 6 6 448797 3 18 17 6 9 7 8 7 17 7 12 9 10 9 11 8 12 125 12 10 10 11 9 12 8 16 9 9 9 9 18 6 6 68 9 12 11 11 11 13 8 36 11 18 15 15 15 15 17 13 13 19 10 20 9 29 16 13 13 13 13 16 12 ...

output:

999999996 999999995 999999994 999999997 999999996 999999995 999999994 999999993 999999998 999999994 999999993 999999992 999999995 999999992 999999993 999999992 999999991 999999994 999999993 999999992 999999996 999999995 999999997 999999996 999999995 999999999 999999998 999999997 1000000000 999999996...

result:

ok 

Test #13:

score: 0
Accepted
time: 84ms
memory: 78080kb

input:

466137
1 466136 5 5 5 5 6 6 4 5 4 10 6 6 6 6 12 7 7 7 7 7 10 4 4 8 5 5 5 9 5 5 5 12 6 6 6 8 5 5 16 5 5 9 7 7 7 7 13 5 5 5 11 7 6 6 7 5 11 5 5 5 10 4 6 5 5 14 9 9 9 9 8 9 8 12 4 4 9 5 5 6 4 18 4 5 6 5 11 9 9 9 9 9 9 16 4 4 12 9 6 6 9 7 7 7 11 3 7 4 5 4 7 3 20 6 6 6 18 6 7 6 9 6 12 8 8 8 10 7 7 22 5 5...

output:

999999999 1000000000 999999998 999999997 999999996 999999995 999999999 999999999 999999997 999999998 999999997 999999999 999999998 999999997 999999996 999999995 999999999 999999998 999999997 999999996 999999995 999999994 999999999 999999998 999999997 999999999 999999998 999999997 999999996 999999999...

result:

ok 

Test #14:

score: 0
Accepted
time: 83ms
memory: 74796kb

input:

447669
3 3 29 3 6 5 5 13 10 9 9 9 10 7 10 12 4 6 4 8 5 6 5 11 7 5 7 6 6 447668 3 6 4 5 4 11 6 6 6 6 7 5 4 4 9 4 6 5 5 11 5 5 6 4 21 4 5 9 7 7 8 6 13 7 8 7 8 9 4 46 4 9 6 7 7 6 11 6 6 9 6 6 14 6 11 8 10 9 9 10 18 6 9 8 8 9 6 11 4 40 5 5 6 5 6 5 6 4 21 4 12 7 7 7 11 8 8 8 8 19 4 8 7 7 7 7 19 4 12 5 11...

output:

999999998 999999997 999999999 999999997 999999998 999999997 999999996 999999998 999999997 999999994 999999993 999999992 999999995 999999994 999999996 999999998 999999997 999999998 999999997 999999998 999999996 999999997 999999996 999999998 999999997 999999995 999999996 999999995 999999994 1000000000...

result:

ok 

Test #15:

score: 0
Accepted
time: 75ms
memory: 68200kb

input:

408826
1 408825 3 4 3 7 4 4 26 18 12 9 9 12 9 10 9 17 10 10 10 10 11 6 23 6 6 8 6 6 25 3 9 5 6 5 7 4 10 4 4 13 4 9 8 8 8 8 9 4 20 6 6 6 9 6 6 8 5 5 21 5 5 11 9 9 9 9 9 9 26 4 9 8 8 8 8 15 7 7 7 10 7 7 7 28 11 11 8 8 11 8 9 8 13 5 5 19 5 5 7 5 5 10 4 4 22 5 8 7 7 7 12 7 7 7 13 9 9 9 9 9 10 4 21 3 11 ...

output:

999999999 1000000000 999999997 999999998 999999997 999999999 999999998 999999997 999999999 999999997 999999995 999999993 999999992 999999994 999999992 999999993 999999992 999999996 999999995 999999994 999999993 999999992 999999996 999999995 999999998 999999996 999999995 999999997 999999996 999999995...

result:

ok 

Test #16:

score: 0
Accepted
time: 85ms
memory: 81104kb

input:

486362
2 8 5 5 5 7 4 4 10 2 3 486351 5 5 5 6 14 9 7 7 9 7 7 13 5 6 6 5 27 11 6 7 6 9 6 8 6 6 15 4 5 4 6 5 4 4 15 5 5 6 6 5 9 6 7 6 7 25 6 6 8 6 6 13 8 8 8 8 9 4 49 27 9 27 10 14 12 13 12 16 12 12 14 11 18 11 12 12 13 12 13 11 27 27 28 8 7 7 7 36 7 7 7 8 5 54 4 19 7 7 7 8 11 10 8 9 9 8 14 6 7 7 6 23 ...

output:

999999998 999999999 999999997 999999996 999999995 999999998 999999997 999999996 1000000000 999999999 1000000000 1000000000 999999997 999999996 999999995 999999998 999999998 999999996 999999994 999999993 999999995 999999994 999999993 999999997 999999995 999999996 999999996 999999995 999999999 9999999...

result:

ok 

Test #17:

score: 0
Accepted
time: 76ms
memory: 74472kb

input:

444506
1 444505 2 3 22 4 10 9 7 8 8 7 15 7 7 9 7 7 14 6 7 7 6 8 23 3 6 4 4 13 10 10 10 10 10 10 10 10 16 7 5 7 6 6 10 4 4 10 7 7 7 7 7 9 3 8 6 6 6 6 10 4 5 4 7 3 7 5 5 5 9 5 5 5 7 3 6 4 4 6 3 5 3 8 6 6 6 6 8 3 5 3 5 3 8 6 6 6 6 8 3 5 3 6 4 4 8 5 5 5 13 9 9 9 9 9 9 9 12 4 4 10 7 5 7 6 6 9 3 6 4 4 9 6...

output:

999999999 1000000000 999999998 999999999 999999999 999999997 999999998 999999997 999999995 999999996 999999996 999999995 999999998 999999996 999999995 999999997 999999996 999999995 999999998 999999995 999999996 999999996 999999995 999999997 999999999 999999998 999999999 999999998 999999997 999999999...

result:

ok 

Test #18:

score: 0
Accepted
time: 82ms
memory: 69688kb

input:

416777
1 416776 4 4 4 8 4 5 4 7 3 7 5 5 5 11 7 7 7 7 7 10 4 4 8 5 5 5 9 4 5 4 9 5 5 5 11 6 6 6 7 4 10 4 4 10 7 7 7 7 7 11 5 5 5 8 4 4 8 5 5 5 11 5 5 7 5 5 11 5 5 5 8 4 4 7 4 4 7 4 4 8 5 5 5 8 4 4 7 4 4 8 5 5 5 10 6 6 6 6 13 8 8 8 7 8 7 11 4 4 6 3 6 4 4 7 4 4 9 6 6 6 6 12 7 5 7 6 6 10 4 4 6 3 5 3 6 4...

output:

999999999 1000000000 999999998 999999997 999999996 999999999 999999997 999999998 999999997 999999999 999999998 999999999 999999998 999999997 999999996 999999999 999999998 999999997 999999996 999999995 999999994 999999999 999999998 999999997 999999999 999999998 999999997 999999996 999999999 999999997...

result:

ok 

Test #19:

score: 0
Accepted
time: 1ms
memory: 3528kb

input:

15
7 7 7 7 9 5 5 11 4 4 13 3 4 2 14

output:

999999996 999999995 999999994 999999993 999999997 999999996 999999995 999999998 999999997 999999996 999999999 999999998 999999999 999999998 1000000000

result:

ok 

Test #20:

score: 0
Accepted
time: 1ms
memory: 3508kb

input:

17
7 7 7 7 9 5 5 11 4 4 13 3 5 3 4 2 16

output:

999999996 999999995 999999994 999999993 999999997 999999996 999999995 999999998 999999997 999999996 999999999 999999998 999999999 999999998 999999999 999999998 1000000000

result:

ok 

Test #21:

score: 0
Accepted
time: 0ms
memory: 3576kb

input:

15
9 8 8 9 7 10 5 12 5 5 13 3 13 14 1

output:

999999995 999999993 999999992 999999994 999999993 999999996 999999995 999999997 999999996 999999995 999999998 999999997 999999999 1000000000 999999999

result:

ok 

Test #22:

score: 0
Accepted
time: 1ms
memory: 3400kb

input:

15
2 6 5 5 5 8 4 4 4 11 2 5 3 3 3

output:

999999998 999999999 999999998 999999997 999999996 999999999 999999998 999999997 999999996 1000000000 999999999 1000000000 999999999 999999998 999999997

result:

ok 

Test #23:

score: 0
Accepted
time: 134ms
memory: 171712kb

input:

500000
499996 499995 499994 499993 499992 499991 499990 499989 499988 499987 499986 499985 499984 499983 499982 499981 499980 499979 499978 499977 499976 499975 499974 499973 499972 499971 499970 499969 499968 499967 499966 499965 499964 499963 499962 499961 499960 499959 499958 499957 499956 499955...

output:

999999999 999999997 999999995 999999993 999999991 999999989 999999987 999999985 999999983 999999981 999999979 999999977 999999975 999999973 999999971 999999969 999999967 999999965 999999963 999999961 999999959 999999957 999999955 999999953 999999951 999999949 999999947 999999945 999999943 999999941 ...

result:

ok 

Test #24:

score: 0
Accepted
time: 86ms
memory: 171732kb

input:

500000
2 3 2 499999 3 499996 5 499995 7 499994 9 499993 11 499992 13 499991 15 499990 17 499989 19 499988 21 499987 23 499986 25 499985 27 499984 29 499983 31 499982 33 499981 35 499980 37 499979 39 499978 41 499977 43 499976 45 499975 47 499974 49 499973 51 499972 53 499971 55 499970 57 499969 59 4...

output:

999999998 999999999 999999998 1000000000 999999997 999999998 999999995 999999996 999999993 999999994 999999991 999999992 999999989 999999990 999999987 999999988 999999985 999999986 999999983 999999984 999999981 999999982 999999979 999999980 999999977 999999978 999999975 999999976 999999973 999999974...

result:

ok 

Test #25:

score: 0
Accepted
time: 95ms
memory: 149452kb

input:

500000
250000 250000 250001 249999 250002 249998 250003 249997 250004 249996 250005 249995 250006 249994 250007 249993 250008 249992 250009 249991 250010 249990 250011 249989 250012 249988 250013 249987 250014 249986 250015 249985 250016 249984 250017 249983 250018 249982 250019 249981 250020 249980...

output:

999750001 999750000 999750002 999750001 999750003 999750002 999750004 999750003 999750005 999750004 999750006 999750005 999750007 999750006 999750008 999750007 999750009 999750008 999750010 999750009 999750011 999750010 999750012 999750011 999750013 999750012 999750014 999750013 999750015 999750014 ...

result:

ok 

Test #26:

score: 0
Accepted
time: 90ms
memory: 149308kb

input:

500000
249759 249759 249760 249758 249761 249757 249762 249756 249763 249755 249764 249754 249765 249753 249766 249752 249767 249751 249768 249750 249769 249749 249770 249748 249771 249747 249772 249746 249773 249745 249774 249744 249775 249743 249776 249742 249777 249741 249778 249740 249779 249739...

output:

999750242 999750241 999750243 999750242 999750244 999750243 999750245 999750244 999750246 999750245 999750247 999750246 999750248 999750247 999750249 999750248 999750250 999750249 999750251 999750250 999750252 999750251 999750253 999750252 999750254 999750253 999750255 999750254 999750256 999750255 ...

result:

ok 

Extra Test:

score: 0
Extra Test Passed