QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#460797#3797. Wireless Communication NetworkAcoippAC ✓61ms71908kbC++144.5kb2024-07-02 09:48:152024-07-02 09:48:17

Judging History

This is the latest submission verdict.

  • [2024-07-02 09:48:17]
  • Judged
  • Verdict: AC
  • Time: 61ms
  • Memory: 71908kb
  • [2024-07-02 09:48:15]
  • Submitted

answer

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

namespace FastIO
{

class FastIOBase
{
 protected:
#ifdef OPENIOBUF
	static const int BUFSIZE=1<<16;
	char buf[BUFSIZE+1];
	int buf_p=0;
#endif
	FILE *target;
	FastIOBase(FILE *f): target(f){}
	~FastIOBase()=default;
 public:
#ifdef OPENIOBUF
	virtual void flush()=0;
#endif
};

class FastOutput final: public FastIOBase
{
 public:
	FastOutput(FILE *f=stdout): FastIOBase(f) {}
#ifdef OPENIOBUF
	~FastOutput() { flush(); }
	void flush() { fwrite(buf,1,buf_p,target),buf_p=0; }
#endif
	void put(char x)
	{
#ifdef OPENIOBUF
		if(buf[buf_p++]=x,buf_p==BUFSIZE) flush();
#else
		putc(x,target);
#endif
	}
	FastOutput &operator <<(char x)
	{ return put(x),*this; }
	FastOutput &operator <<(const char *s)
	{ for(;*s;put(*(s++)));return *this; }
	FastOutput &operator <<(const std::string &s)
	{ return (*this)<<s.c_str(); }
	template<typename T>
	std::enable_if_t<std::is_integral<T>::value,FastOutput&> operator <<(T x)
	{
		if(x<0) return put('-'),operator<<(-x);
		char stk[numeric_limits<T>::digits10+1],*top=stk;
		do *(top++)=x%10+'0',x/=10; while(x);
		for(;top!=stk;put(*--top));
		return *this;
	}
	template<typename ...T>
	void writesp(const T &...x)
	{ std::initializer_list<int>{(this->operator<<(x),put(' '),0)...}; }
	template<typename ...T>
	void writeln(const T &...x)
	{ std::initializer_list<int>{(this->operator<<(x),put('\n'),0)...}; }
	template<typename Iter>
	void writesp(Iter begin,Iter end)
	{ while(begin!=end) (*this)<<*(begin++)<<' '; }
	template<typename Iter>
	void writeln(Iter begin,Iter end)
	{ while(begin!=end) (*this)<<*(begin++)<<'\n'; }
}qout;

class FastInput final: public FastIOBase
{
 private:
	bool __eof;
 public:
	FastInput(FILE *f=stdin): FastIOBase(f),__eof(false)
#ifdef OPENIOBUF
	{ buf_p=BUFSIZE; }
	void flush() { buf[fread(buf,1,BUFSIZE,target)]=EOF,buf_p=0; }
	bool eof()const { return buf[buf_p]==EOF; }
#else
	{}
	bool eof()const { return feof(target); }
#endif
	char get()
	{
		if(__eof) return EOF;
#ifdef OPENIOBUF
		if(buf_p==BUFSIZE) flush();
		char ch=buf[buf_p++];
#else
		char ch=getc(target);
#endif
		return ~ch?ch:(__eof=true,EOF);
	}
	void unget(char c)
	{
		__eof=false;
#ifdef OPENIOBUF
		buf[--buf_p]=c;
#else
		ungetc(c,target);
#endif
	}
	explicit operator bool()const { return !__eof; }
	FastInput &operator >>(char &x)
	{ while(isspace(x=get()));return *this; }
	template<typename T>
	std::enable_if_t<std::is_integral<T>::value,FastInput&> operator >>(T &x)
	{
		char ch,sym=0;x=0;
		while(isspace(ch=get()));
		if(__eof) return *this;
		if(ch=='-') sym=1,ch=get();
		for(;isdigit(ch);x=(x<<1)+(x<<3)+(ch^48),ch=get());
		return unget(ch),sym?x=-x:x,*this;
	}
	FastInput &operator >>(char *s)
	{
		while(isspace(*s=get()));
		if(__eof) return *this;
		for(;!isspace(*s) && !__eof;*(++s)=get());
		return unget(*s),*s='\0',*this;
	}
	FastInput &operator >>(std::string &s)
	{
		char str_buf[(1<<8)+1]={0},*p=str_buf;
		char *const buf_end=str_buf+(1<<8);
		while(isspace(*p=get()));
		if(__eof) return *this;
		for(s.clear(),p++;;p=str_buf)
		{
			for(;p!=buf_end && !isspace(*p=get()) && !__eof;p++);
			if(p!=buf_end) break;
			s.append(str_buf);
		}
		unget(*p),*p='\0',s.append(str_buf);
		return *this;
	}
	template<typename ...T>
	void read(T &...x)
	{ std::initializer_list<int>{(this->operator>>(x),0)...}; }
	template<typename Iter>
	void read(Iter begin,Iter end)
	{ while(begin!=end) (*this)>>*(begin++); }
}qin;

} // namespace FastIO
using FastIO::qin,FastIO::qout;

using LL=long long;
using LD=long double;
using UI=unsigned int;
using ULL=unsigned long long;

#ifndef DADALZY
#define FILEIO(file) freopen(file".in","r",stdin),freopen(file".out","w",stdout)
#define LOG(...) [](auto...){}(__VA_ARGS__)
#else
#define FILEIO(file)
#define LOG(...) fprintf(stderr,__VA_ARGS__)
#endif

int n,a[1000005],lc[1000005],rc[1000005];
vector<int> G[1000005];

int build()
{
	static int stk[1000005];
	int top=0;
	for(int i=1;i<=n;i++)
	{
		int k=top;
		while(k && a[stk[k]]<a[i]) k--;
		if(k) rc[stk[k]]=i;
		if(k<top) lc[i]=stk[k+1];
		stk[top=++k]=i;
	}
	return stk[1];
}
pair<int,int> dfs(int u)
{
	if(!u) return make_pair(-1,-1);
	auto l=dfs(lc[u]),r=dfs(rc[u]);
	return make_pair(
		max(l.first,r.first)+1,
		max({l.second+1,r.second+1,l.first+r.first+2})
	);
}

int main()
{
	qin>>n;
	qin.read(a+1,a+n+1);
	int rt=build();
	qout<<dfs(rt).second<<'\n';
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 56ms
memory: 40016kb

input:

1000000
113501
958200
129777
204669
144689
505829
196620
372713
150467
264501
551022
435761
764113
642344
28014
882720
994040
530166
192364
711438
611510
38183
574666
655695
582851
103474
43636
994936
663384
174586
621996
560209
686491
894160
493610
924045
54482
84945
2479
958324
330979
288441
90205...

output:

91

result:

ok single line: '91'

Test #2:

score: 0
Accepted
time: 46ms
memory: 39644kb

input:

888888
113501
129776
204668
144688
505828
196619
372712
150466
264500
551021
435760
764112
642343
28013
882719
530164
192362
711436
611508
38181
574664
655693
582849
103472
43634
663381
174583
621993
560206
686488
493606
54477
84940
2474
330973
288435
35306
44146
667284
104067
244335
737772
724728
6...

output:

95

result:

ok single line: '95'

Test #3:

score: 0
Accepted
time: 61ms
memory: 38996kb

input:

999990
113501
958200
129777
204669
144689
505829
196620
372713
150467
264501
551022
435761
764113
642344
28014
882720
994040
530166
192364
711438
611510
38183
574666
655695
582851
103474
43636
994936
663384
174586
621996
560209
686491
894160
493610
924045
54482
84945
2479
958324
330979
288441
902059...

output:

94

result:

ok single line: '94'

Test #4:

score: 0
Accepted
time: 48ms
memory: 40852kb

input:

999992
113501
958200
129777
204669
144689
505829
196620
372713
150467
264501
551022
435761
764113
642344
28014
882720
994040
530166
192364
711438
611510
38183
574666
655695
582851
103474
43636
994936
663384
174586
621996
560209
686491
894160
493610
924045
54482
84945
2479
958324
330979
288441
902059...

output:

94

result:

ok single line: '94'

Test #5:

score: 0
Accepted
time: 56ms
memory: 40696kb

input:

999994
113501
958200
129777
204669
144689
505829
196620
372713
150467
264501
551022
435761
764113
642344
28014
882720
994040
530166
192364
711438
611510
38183
574666
655695
582851
103474
43636
994936
663384
174586
621996
560209
686491
894160
493610
924045
54482
84945
2479
958324
330979
288441
902059...

output:

99

result:

ok single line: '99'

Test #6:

score: 0
Accepted
time: 52ms
memory: 40172kb

input:

999996
113501
958200
129777
204669
144689
505829
196620
372713
150467
264501
551022
435761
764113
642344
28014
882720
994040
530166
192364
711438
611510
38183
574666
655695
582851
103474
43636
994936
663384
174586
621996
560209
686491
894160
493610
924045
54482
84945
2479
958324
330979
288441
902059...

output:

92

result:

ok single line: '92'

Test #7:

score: 0
Accepted
time: 51ms
memory: 39356kb

input:

999999
113501
958200
129777
204669
144689
505829
196620
372713
150467
264501
551022
435761
764113
642344
28014
882720
994040
530166
192364
711438
611510
38183
574666
655695
582851
103474
43636
994936
663384
174586
621996
560209
686491
894160
493610
924045
54482
84945
2479
958324
330979
288441
902059...

output:

92

result:

ok single line: '92'

Test #8:

score: 0
Accepted
time: 50ms
memory: 71908kb

input:

999997
999997
999996
999995
999994
999993
999992
999991
999990
999989
999988
999987
999986
999985
999984
999983
999982
999981
999980
999979
999978
999977
999976
999975
999974
999973
999972
999971
999970
999969
999968
999967
999966
999965
999964
999963
999962
999961
999960
999959
999958
999957
999956...

output:

999996

result:

ok single line: '999996'

Test #9:

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

input:

999998
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
1...

output:

999997

result:

ok single line: '999997'

Test #10:

score: 0
Accepted
time: 8ms
memory: 34628kb

input:

3
1
2
3

output:

2

result:

ok single line: '2'

Test #11:

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

input:

3
1
3
2

output:

2

result:

ok single line: '2'

Test #12:

score: 0
Accepted
time: 3ms
memory: 34372kb

input:

3
2
1
3

output:

2

result:

ok single line: '2'

Test #13:

score: 0
Accepted
time: 6ms
memory: 33360kb

input:

3
2
3
1

output:

2

result:

ok single line: '2'

Test #14:

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

input:

3
3
1
2

output:

2

result:

ok single line: '2'

Test #15:

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

input:

3
3
2
1

output:

2

result:

ok single line: '2'

Test #16:

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

input:

4
1
2
3
4

output:

3

result:

ok single line: '3'

Test #17:

score: 0
Accepted
time: 7ms
memory: 33380kb

input:

4
1
2
4
3

output:

3

result:

ok single line: '3'

Test #18:

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

input:

4
1
3
2
4

output:

3

result:

ok single line: '3'

Test #19:

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

input:

4
1
3
4
2

output:

3

result:

ok single line: '3'

Test #20:

score: 0
Accepted
time: 3ms
memory: 33840kb

input:

4
1
4
2
3

output:

3

result:

ok single line: '3'

Test #21:

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

input:

4
1
4
3
2

output:

3

result:

ok single line: '3'

Test #22:

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

input:

4
2
1
3
4

output:

3

result:

ok single line: '3'

Test #23:

score: 0
Accepted
time: 7ms
memory: 34236kb

input:

4
2
1
4
3

output:

3

result:

ok single line: '3'

Test #24:

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

input:

4
2
3
1
4

output:

3

result:

ok single line: '3'

Test #25:

score: 0
Accepted
time: 3ms
memory: 34760kb

input:

4
2
3
4
1

output:

3

result:

ok single line: '3'

Test #26:

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

input:

4
2
4
1
3

output:

3

result:

ok single line: '3'

Test #27:

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

input:

4
2
4
3
1

output:

3

result:

ok single line: '3'

Test #28:

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

input:

4
3
1
2
4

output:

3

result:

ok single line: '3'

Test #29:

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

input:

4
3
1
4
2

output:

3

result:

ok single line: '3'

Test #30:

score: 0
Accepted
time: 3ms
memory: 35036kb

input:

4
3
2
1
4

output:

3

result:

ok single line: '3'

Test #31:

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

input:

4
3
2
4
1

output:

3

result:

ok single line: '3'

Test #32:

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

input:

4
3
4
1
2

output:

3

result:

ok single line: '3'

Test #33:

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

input:

4
3
4
2
1

output:

3

result:

ok single line: '3'

Test #34:

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

input:

4
4
1
2
3

output:

3

result:

ok single line: '3'

Test #35:

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

input:

4
4
1
3
2

output:

3

result:

ok single line: '3'

Test #36:

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

input:

4
4
2
1
3

output:

3

result:

ok single line: '3'

Test #37:

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

input:

4
4
2
3
1

output:

3

result:

ok single line: '3'

Test #38:

score: 0
Accepted
time: 3ms
memory: 35164kb

input:

4
4
3
1
2

output:

3

result:

ok single line: '3'

Test #39:

score: 0
Accepted
time: 2ms
memory: 31480kb

input:

4
4
3
2
1

output:

3

result:

ok single line: '3'

Test #40:

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

input:

5
1
2
3
4
5

output:

4

result:

ok single line: '4'

Test #41:

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

input:

5
1
2
3
5
4

output:

4

result:

ok single line: '4'

Test #42:

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

input:

5
1
2
4
3
5

output:

4

result:

ok single line: '4'

Test #43:

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

input:

5
1
2
4
5
3

output:

4

result:

ok single line: '4'

Test #44:

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

input:

5
1
2
5
3
4

output:

4

result:

ok single line: '4'

Test #45:

score: 0
Accepted
time: 7ms
memory: 34244kb

input:

5
1
2
5
4
3

output:

4

result:

ok single line: '4'

Test #46:

score: 0
Accepted
time: 2ms
memory: 34736kb

input:

5
1
3
2
4
5

output:

4

result:

ok single line: '4'

Test #47:

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

input:

5
1
3
2
5
4

output:

3

result:

ok single line: '3'

Test #48:

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

input:

5
1
3
4
2
5

output:

4

result:

ok single line: '4'

Test #49:

score: 0
Accepted
time: 6ms
memory: 34404kb

input:

5
1
3
4
5
2

output:

4

result:

ok single line: '4'

Test #50:

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

input:

5
1
3
5
2
4

output:

4

result:

ok single line: '4'

Test #51:

score: 0
Accepted
time: 6ms
memory: 34284kb

input:

5
1
3
5
4
2

output:

4

result:

ok single line: '4'

Test #52:

score: 0
Accepted
time: 5ms
memory: 34468kb

input:

5
1
4
2
3
5

output:

4

result:

ok single line: '4'

Test #53:

score: 0
Accepted
time: 6ms
memory: 34312kb

input:

5
1
4
2
5
3

output:

3

result:

ok single line: '3'

Test #54:

score: 0
Accepted
time: 3ms
memory: 33320kb

input:

5
1
4
3
2
5

output:

4

result:

ok single line: '4'

Test #55:

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

input:

5
1
4
3
5
2

output:

3

result:

ok single line: '3'

Test #56:

score: 0
Accepted
time: 6ms
memory: 34116kb

input:

5
1
4
5
2
3

output:

4

result:

ok single line: '4'

Test #57:

score: 0
Accepted
time: 3ms
memory: 33424kb

input:

5
1
4
5
3
2

output:

4

result:

ok single line: '4'

Test #58:

score: 0
Accepted
time: 3ms
memory: 34244kb

input:

5
1
5
2
3
4

output:

4

result:

ok single line: '4'

Test #59:

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

input:

5
1
5
2
4
3

output:

3

result:

ok single line: '3'

Test #60:

score: 0
Accepted
time: 3ms
memory: 35164kb

input:

5
1
5
3
2
4

output:

4

result:

ok single line: '4'

Test #61:

score: 0
Accepted
time: 3ms
memory: 33440kb

input:

5
1
5
3
4
2

output:

3

result:

ok single line: '3'

Test #62:

score: 0
Accepted
time: 3ms
memory: 33500kb

input:

5
1
5
4
2
3

output:

4

result:

ok single line: '4'

Test #63:

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

input:

5
1
5
4
3
2

output:

4

result:

ok single line: '4'

Test #64:

score: 0
Accepted
time: 3ms
memory: 33500kb

input:

5
2
1
3
4
5

output:

4

result:

ok single line: '4'

Test #65:

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

input:

5
2
1
3
5
4

output:

4

result:

ok single line: '4'

Test #66:

score: 0
Accepted
time: 5ms
memory: 34932kb

input:

5
2
1
4
3
5

output:

4

result:

ok single line: '4'

Test #67:

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

input:

5
2
1
4
5
3

output:

4

result:

ok single line: '4'

Test #68:

score: 0
Accepted
time: 7ms
memory: 33584kb

input:

5
2
1
5
3
4

output:

4

result:

ok single line: '4'

Test #69:

score: 0
Accepted
time: 6ms
memory: 33544kb

input:

5
2
1
5
4
3

output:

4

result:

ok single line: '4'

Test #70:

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

input:

5
2
3
1
4
5

output:

4

result:

ok single line: '4'

Test #71:

score: 0
Accepted
time: 3ms
memory: 34648kb

input:

5
2
3
1
5
4

output:

3

result:

ok single line: '3'

Test #72:

score: 0
Accepted
time: 6ms
memory: 34440kb

input:

5
2
3
4
1
5

output:

4

result:

ok single line: '4'

Test #73:

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

input:

5
2
3
4
5
1

output:

4

result:

ok single line: '4'

Test #74:

score: 0
Accepted
time: 3ms
memory: 35056kb

input:

5
2
3
5
1
4

output:

4

result:

ok single line: '4'

Test #75:

score: 0
Accepted
time: 4ms
memory: 34612kb

input:

5
2
3
5
4
1

output:

4

result:

ok single line: '4'

Test #76:

score: 0
Accepted
time: 3ms
memory: 33304kb

input:

5
2
4
1
3
5

output:

4

result:

ok single line: '4'

Test #77:

score: 0
Accepted
time: 3ms
memory: 34884kb

input:

5
2
4
1
5
3

output:

3

result:

ok single line: '3'

Test #78:

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

input:

5
2
4
3
1
5

output:

4

result:

ok single line: '4'

Test #79:

score: 0
Accepted
time: 3ms
memory: 33760kb

input:

5
2
4
3
5
1

output:

3

result:

ok single line: '3'

Test #80:

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

input:

5
2
4
5
1
3

output:

4

result:

ok single line: '4'

Test #81:

score: 0
Accepted
time: 5ms
memory: 33472kb

input:

5
2
4
5
3
1

output:

4

result:

ok single line: '4'

Test #82:

score: 0
Accepted
time: 6ms
memory: 34408kb

input:

5
2
5
1
3
4

output:

4

result:

ok single line: '4'

Test #83:

score: 0
Accepted
time: 3ms
memory: 34528kb

input:

5
2
5
1
4
3

output:

3

result:

ok single line: '3'

Test #84:

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

input:

5
2
5
3
1
4

output:

4

result:

ok single line: '4'

Test #85:

score: 0
Accepted
time: 3ms
memory: 33732kb

input:

5
2
5
3
4
1

output:

3

result:

ok single line: '3'

Test #86:

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

input:

5
2
5
4
1
3

output:

4

result:

ok single line: '4'

Test #87:

score: 0
Accepted
time: 7ms
memory: 34212kb

input:

5
2
5
4
3
1

output:

4

result:

ok single line: '4'

Test #88:

score: 0
Accepted
time: 6ms
memory: 34244kb

input:

5
3
1
2
4
5

output:

4

result:

ok single line: '4'

Test #89:

score: 0
Accepted
time: 3ms
memory: 34356kb

input:

5
3
1
2
5
4

output:

4

result:

ok single line: '4'

Test #90:

score: 0
Accepted
time: 6ms
memory: 34040kb

input:

5
3
1
4
2
5

output:

4

result:

ok single line: '4'

Test #91:

score: 0
Accepted
time: 3ms
memory: 33376kb

input:

5
3
1
4
5
2

output:

4

result:

ok single line: '4'

Test #92:

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

input:

5
3
1
5
2
4

output:

4

result:

ok single line: '4'

Test #93:

score: 0
Accepted
time: 7ms
memory: 33896kb

input:

5
3
1
5
4
2

output:

4

result:

ok single line: '4'

Test #94:

score: 0
Accepted
time: 3ms
memory: 34940kb

input:

5
3
2
1
4
5

output:

4

result:

ok single line: '4'

Test #95:

score: 0
Accepted
time: 3ms
memory: 35108kb

input:

5
3
2
1
5
4

output:

4

result:

ok single line: '4'

Test #96:

score: 0
Accepted
time: 5ms
memory: 33508kb

input:

5
3
2
4
1
5

output:

4

result:

ok single line: '4'

Test #97:

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

input:

5
3
2
4
5
1

output:

4

result:

ok single line: '4'

Test #98:

score: 0
Accepted
time: 3ms
memory: 33128kb

input:

5
3
2
5
1
4

output:

4

result:

ok single line: '4'

Test #99:

score: 0
Accepted
time: 3ms
memory: 33540kb

input:

5
3
2
5
4
1

output:

4

result:

ok single line: '4'

Test #100:

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

input:

5
3
4
1
2
5

output:

4

result:

ok single line: '4'

Test #101:

score: 0
Accepted
time: 3ms
memory: 33220kb

input:

5
3
4
1
5
2

output:

3

result:

ok single line: '3'

Test #102:

score: 0
Accepted
time: 5ms
memory: 34764kb

input:

5
3
4
2
1
5

output:

4

result:

ok single line: '4'

Test #103:

score: 0
Accepted
time: 5ms
memory: 33296kb

input:

5
3
4
2
5
1

output:

3

result:

ok single line: '3'

Test #104:

score: 0
Accepted
time: 3ms
memory: 33256kb

input:

5
3
4
5
1
2

output:

4

result:

ok single line: '4'

Test #105:

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

input:

5
3
4
5
2
1

output:

4

result:

ok single line: '4'

Test #106:

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

input:

5
3
5
1
2
4

output:

4

result:

ok single line: '4'

Test #107:

score: 0
Accepted
time: 6ms
memory: 34448kb

input:

5
3
5
1
4
2

output:

3

result:

ok single line: '3'

Test #108:

score: 0
Accepted
time: 3ms
memory: 33804kb

input:

5
3
5
2
1
4

output:

4

result:

ok single line: '4'

Test #109:

score: 0
Accepted
time: 6ms
memory: 35064kb

input:

5
3
5
2
4
1

output:

3

result:

ok single line: '3'

Test #110:

score: 0
Accepted
time: 7ms
memory: 33640kb

input:

5
3
5
4
1
2

output:

4

result:

ok single line: '4'

Test #111:

score: 0
Accepted
time: 3ms
memory: 34900kb

input:

5
3
5
4
2
1

output:

4

result:

ok single line: '4'

Test #112:

score: 0
Accepted
time: 5ms
memory: 33480kb

input:

5
4
1
2
3
5

output:

4

result:

ok single line: '4'

Test #113:

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

input:

5
4
1
2
5
3

output:

4

result:

ok single line: '4'

Test #114:

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

input:

5
4
1
3
2
5

output:

4

result:

ok single line: '4'

Test #115:

score: 0
Accepted
time: 6ms
memory: 33232kb

input:

5
4
1
3
5
2

output:

4

result:

ok single line: '4'

Test #116:

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

input:

5
4
1
5
2
3

output:

4

result:

ok single line: '4'

Test #117:

score: 0
Accepted
time: 6ms
memory: 33860kb

input:

5
4
1
5
3
2

output:

4

result:

ok single line: '4'

Test #118:

score: 0
Accepted
time: 2ms
memory: 33448kb

input:

5
4
2
1
3
5

output:

4

result:

ok single line: '4'

Test #119:

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

input:

5
4
2
1
5
3

output:

4

result:

ok single line: '4'

Test #120:

score: 0
Accepted
time: 3ms
memory: 33500kb

input:

5
4
2
3
1
5

output:

4

result:

ok single line: '4'

Test #121:

score: 0
Accepted
time: 3ms
memory: 33768kb

input:

5
4
2
3
5
1

output:

4

result:

ok single line: '4'

Test #122:

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

input:

5
4
2
5
1
3

output:

4

result:

ok single line: '4'

Test #123:

score: 0
Accepted
time: 6ms
memory: 33308kb

input:

5
4
2
5
3
1

output:

4

result:

ok single line: '4'

Test #124:

score: 0
Accepted
time: 3ms
memory: 34392kb

input:

5
4
3
1
2
5

output:

4

result:

ok single line: '4'

Test #125:

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

input:

5
4
3
1
5
2

output:

4

result:

ok single line: '4'

Test #126:

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

input:

5
4
3
2
1
5

output:

4

result:

ok single line: '4'

Test #127:

score: 0
Accepted
time: 5ms
memory: 35272kb

input:

5
4
3
2
5
1

output:

4

result:

ok single line: '4'

Test #128:

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

input:

5
4
3
5
1
2

output:

4

result:

ok single line: '4'

Test #129:

score: 0
Accepted
time: 7ms
memory: 33900kb

input:

5
4
3
5
2
1

output:

4

result:

ok single line: '4'

Test #130:

score: 0
Accepted
time: 3ms
memory: 33376kb

input:

5
4
5
1
2
3

output:

4

result:

ok single line: '4'

Test #131:

score: 0
Accepted
time: 3ms
memory: 33612kb

input:

5
4
5
1
3
2

output:

3

result:

ok single line: '3'

Test #132:

score: 0
Accepted
time: 5ms
memory: 33464kb

input:

5
4
5
2
1
3

output:

4

result:

ok single line: '4'

Test #133:

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

input:

5
4
5
2
3
1

output:

3

result:

ok single line: '3'

Test #134:

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

input:

5
4
5
3
1
2

output:

4

result:

ok single line: '4'

Test #135:

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

input:

5
4
5
3
2
1

output:

4

result:

ok single line: '4'

Test #136:

score: 0
Accepted
time: 6ms
memory: 34860kb

input:

5
5
1
2
3
4

output:

4

result:

ok single line: '4'

Test #137:

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

input:

5
5
1
2
4
3

output:

4

result:

ok single line: '4'

Test #138:

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

input:

5
5
1
3
2
4

output:

4

result:

ok single line: '4'

Test #139:

score: 0
Accepted
time: 7ms
memory: 35044kb

input:

5
5
1
3
4
2

output:

4

result:

ok single line: '4'

Test #140:

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

input:

5
5
1
4
2
3

output:

4

result:

ok single line: '4'

Test #141:

score: 0
Accepted
time: 6ms
memory: 33932kb

input:

5
5
1
4
3
2

output:

4

result:

ok single line: '4'

Test #142:

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

input:

5
5
2
1
3
4

output:

4

result:

ok single line: '4'

Test #143:

score: 0
Accepted
time: 5ms
memory: 34480kb

input:

5
5
2
1
4
3

output:

4

result:

ok single line: '4'

Test #144:

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

input:

5
5
2
3
1
4

output:

4

result:

ok single line: '4'

Test #145:

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

input:

5
5
2
3
4
1

output:

4

result:

ok single line: '4'

Test #146:

score: 0
Accepted
time: 3ms
memory: 33388kb

input:

5
5
2
4
1
3

output:

4

result:

ok single line: '4'

Test #147:

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

input:

5
5
2
4
3
1

output:

4

result:

ok single line: '4'

Test #148:

score: 0
Accepted
time: 5ms
memory: 33856kb

input:

5
5
3
1
2
4

output:

4

result:

ok single line: '4'

Test #149:

score: 0
Accepted
time: 5ms
memory: 34500kb

input:

5
5
3
1
4
2

output:

4

result:

ok single line: '4'

Test #150:

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

input:

5
5
3
2
1
4

output:

4

result:

ok single line: '4'

Test #151:

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

input:

5
5
3
2
4
1

output:

4

result:

ok single line: '4'

Test #152:

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

input:

5
5
3
4
1
2

output:

4

result:

ok single line: '4'

Test #153:

score: 0
Accepted
time: 7ms
memory: 34884kb

input:

5
5
3
4
2
1

output:

4

result:

ok single line: '4'

Test #154:

score: 0
Accepted
time: 3ms
memory: 34828kb

input:

5
5
4
1
2
3

output:

4

result:

ok single line: '4'

Test #155:

score: 0
Accepted
time: 3ms
memory: 33996kb

input:

5
5
4
1
3
2

output:

4

result:

ok single line: '4'

Test #156:

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

input:

5
5
4
2
1
3

output:

4

result:

ok single line: '4'

Test #157:

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

input:

5
5
4
2
3
1

output:

4

result:

ok single line: '4'

Test #158:

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

input:

5
5
4
3
1
2

output:

4

result:

ok single line: '4'

Test #159:

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

input:

5
5
4
3
2
1

output:

4

result:

ok single line: '4'

Test #160:

score: 0
Accepted
time: 45ms
memory: 39092kb

input:

999990
113501
770045
433912
639689
129777
552281
204669
976248
144689
884673
196619
590373
372712
686748
150466
724171
264500
739072
26733
545096
435760
940046
239824
831828
118055
605352
28013
524129
358431
694859
469751
641516
5877
868142
192363
991350
187149
530815
87221
661716
38182
911647
50377...

output:

95

result:

ok single line: '95'

Test #161:

score: 0
Accepted
time: 50ms
memory: 40604kb

input:

999992
113501
770046
433912
639690
129777
552282
204669
976249
144689
884674
196619
590374
372712
686749
150466
724172
264500
739073
26733
545097
435760
940047
239824
831829
118055
605353
28013
524130
358431
694860
469751
641517
5877
868143
192363
991351
187149
530816
87221
661717
38182
911648
50377...

output:

89

result:

ok single line: '89'

Test #162:

score: 0
Accepted
time: 53ms
memory: 40200kb

input:

999994
113501
770047
433912
639691
129777
552283
204669
976250
144689
884675
196619
590375
372712
686750
150466
724173
264500
739074
26733
545098
435760
940048
239824
831830
118055
605354
28013
524131
358431
694861
469751
641518
5877
868144
192363
991352
187149
530817
87221
661718
38182
911649
50377...

output:

92

result:

ok single line: '92'

Test #163:

score: 0
Accepted
time: 49ms
memory: 38876kb

input:

999996
113501
770048
433912
639692
129777
552284
204669
976251
144689
884676
196619
590376
372712
686751
150466
724174
264500
739075
26733
545099
435760
940049
239824
831831
118055
605355
28013
524132
358431
694862
469751
641519
5877
868145
192363
991353
187149
530818
87221
661719
38182
911650
50377...

output:

90

result:

ok single line: '90'