QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#461556#3797. Wireless Communication NetworkRong7AC ✓1205ms111792kbC++146.6kb2024-07-02 20:18:082024-07-02 20:18:08

Judging History

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

  • [2024-07-02 20:18:08]
  • 评测
  • 测评结果:AC
  • 用时:1205ms
  • 内存:111792kb
  • [2024-07-02 20:18:08]
  • 提交

answer

// Not afraid to dark.

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

clock_t start_time, end_time;
#define GET_START start_time = clock ();
#define GET_END end_time = clock (); fprintf (stderr, "TIME COSSEMED : %0.3lf\n", 1.0 * (end_time - start_time) / CLOCKS_PER_SEC);
#define inline __inline__ __attribute__ ((always_inline))

namespace io {
    int read_pos, read_dt; char read_char;
    inline int read (int &p = read_pos){
        p = 0, read_dt = 1; read_char = getchar ();
        while (! isdigit (read_char)){
            if (read_char == '-')
                read_dt = - 1;
            read_char = getchar ();
        }
        while (isdigit (read_char)){
            p = (p << 1) + (p << 3) + read_char - 48;
            read_char = getchar ();
        }
        return p = p * read_dt;
    }
    int write_sta[65], write_top;
    inline void write (int x){
        if (x < 0)
            putchar ('-'), x = - x;
        write_top = 0;
        do
            write_sta[write_top ++] = x % 10, x /= 10;
        while (x);
        while (write_top)
            putchar (write_sta[-- write_top] + 48);
    }
    // int llen;
    // inline int get_string (char c[], int &len = llen){
    //     len = 0;
    //     read_char = getchar ();
    //     while (read_char == ' ' || read_char == '\n' || read_char == '\r')
    //         read_char = getchar ();
    //     while (read_char != ' ' && read_char != '\n' && read_char != '\r'){
    //         c[++ len] = read_char;
    //         read_char = getchar ();
    //     }
    //     return len;
    // }
}

const int N = 1e6;
int n, a[N + 5];
// char c[N + 5];
int pre[N + 5], suf[N + 5];
int top, sta[N + 5];

namespace SGT {
    #define lson(p) ((p) << 1)
    #define rson(p) ((p) << 1 | 1)
    const int S = N << 2;
    int tag[S + 5], mx[S + 5], lt[S + 5], rt[S + 5], la[S + 5], ra[S + 5];
    bool flg[S + 5];
    auto put_tag = [] (int p, int t){ tag[p] += t; mx[p] += t; la[p] += t; ra[p] += t; };
    auto push_tag = [] (int p){
        if (lt[p] != rt[p])
            put_tag (lson (p), tag[p]), put_tag (rson (p), tag[p]);
        tag[p] = 0;
    };
    auto push_up = [] (int p){
        mx[p] = tag[p];
        flg[p] = (lt[p] == rt[p] || (flg[lson (p)] && flg[rson (p)] && (ra[lson (p)] <= la[rson (p)] + 1 || lt[rson (p)] > top)));
        if (lt[p] != rt[p])
            la[p] = la[lson (p)] + tag[p],
            ra[p] = ra[rson (p)] + tag[p],
            mx[p] += max (mx[lson (p)], mx[rson (p)]);
        else
            la[p] = ra[p] = tag[p];
    };
    void Build (int p = 1, int l = 1, int r = n){
        tag[p] = mx[p] = la[p] = ra[p] = 0, lt[p] = l, rt[p] = r;
        flg[p] = true;
        if (l == r)
            return ;
        int mid = (l + r) >> 1;
        Build (lson (p), l, mid);
        Build (rson (p), mid + 1, r);
        push_up (p);
    }
    void Add (int l, int r, int t, int p = 1){
        if (l > r)
            return ;
        if (l <= lt[p] && rt[p] <= r){
            put_tag (p, t);
            return ;
        }
        int mid = (lt[p] + rt[p]) >> 1;
        if (l <= mid)
            Add (l, r, t, lson (p));
        if (r > mid)
            Add (l, r, t, rson (p));
        push_up (p);
    }
    inline int Last (){
        static int p, mid;
        p = 1;
        while (true){
            if (lt[p] == rt[p])
                return lt[p];
            mid = (lt[p] + rt[p]) >> 1;
            if (! flg[rson (p)])
                p = rson (p);
            else
            if (! (ra[lson (p)] <= la[rson (p)] + 1 || lt[rson (p)] > top))
                return mid + 1;
            else
                p = lson (p);
        }
    }
    inline int Query (int x){
        static int p, mid, res;
        if (x == 0)
            return 0;
        p = 1, res = 0;
        while (true){
            res += tag[p];
            if (lt[p] == rt[p])
                break;
            mid = (lt[p] + rt[p]) >> 1;
            if (x <= mid)
                p = lson (p);
            else
                p = rson (p);
        }
        return res;
    }
    inline void Erase (int x){
        static int p, mid;
        p = 1;
        while (true){
            push_tag (p);
            if (lt[p] == rt[p])
                break;
            mid = (lt[p] + rt[p]) >> 1;
            if (x <= mid)
                p = lson (p);
            else
                p = rson (p);
        }
        mx[p] = 0;
        while (true){
            push_up (p);
            if (p == 1)
                break;
            p >>= 1;
        }
    }
} using namespace SGT;

int idx, px[N + 5], sx[N + 5];
int pm[N + 5], sm[N + 5];
int pt[N + 5], st[N + 5], ton[N + 5];

auto imax = [] (const int i, const int j){
    return a[i] > a[j] ? i : j;
};

inline void ARKNIGHTS (){
    io::read (n);
    for (int i = 1;i <= n;++ i)
        io::read (a[i]), idx = (a[i] == n) ? i : idx;
    for (int i = 1;i <= n;++ i){
        px[i] = max (px[i - 1], a[i]);
        pm[i] = imax (pm[i - 1], i);
    }
    for (int i = n, las = 0;i >= 1;-- i){
        if (pm[i] == i)
            las = i;
        pm[i] = las;
    }
    sx[n + 1] = sm[n + 1] = 0;
    for (int i = n;i >= 1;-- i){
        sx[i] = max (sx[i + 1], a[i]);
        sm[i] = imax (sm[i + 1], i);
    }
    for (int i = 1, las = 0;i <= n;++ i){
        if (sm[i] == i)
            las = i;
        sm[i] = las;
    }
    // io::get_string (c);
    Build ();
    top = 0;
    for (int i = 1, x, p;i <= n;++ i){
        x = 0;
        while (top > 0 && sta[top] < a[i]){
            x = Query (top);
            Erase (top);
            -- top;
        }
        sta[++ top] = a[i];
        ton[i] = top;
        Add (top, top, x);
        p = Last ();
        Add (p, top, 1);
        pre[i] = mx[1];
        pt[i] = Query (ton[sm[i]]);
    }
    Build ();
    top = 0;
    suf[n + 1] = st[n + 1] = 0;
    for (int i = n, x, p;i >= 1;-- i){
        x = 0;
        while (top > 0 && sta[top] < a[i]){
            x = Query (top);
            Erase (top);
            -- top;
        }
        sta[++ top] = a[i];
        ton[i] = top;
        Add (top, top, x);
        p = Last ();
        Add (p, top, 1);
        suf[i] = mx[1];
        st[i] = Query (ton[pm[i]]);
    }
    suf[n + 1] = 0;
    int ans = max (pre[n], suf[1]);
    for (int i = 1;i < n;++ i){
        ans = max (ans, pre[i] + suf[i + 1]);
        // ans = max (ans, pre[i] + st[i + 1]);
    }
    io::write (ans - 1), putchar ('\n');
}

signed main (){
    GET_START

    for (int T = 1;T --;)
        ARKNIGHTS ();

    GET_END
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1199ms
memory: 109764kb

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: 1054ms
memory: 110144kb

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: 1185ms
memory: 109760kb

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: 1205ms
memory: 109720kb

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: 1202ms
memory: 111744kb

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: 1185ms
memory: 109764kb

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: 1180ms
memory: 109824kb

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: 1098ms
memory: 111788kb

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: 1079ms
memory: 111792kb

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: 0ms
memory: 32620kb

input:

3
1
2
3

output:

2

result:

ok single line: '2'

Test #11:

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

input:

3
1
3
2

output:

2

result:

ok single line: '2'

Test #12:

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

input:

3
2
1
3

output:

2

result:

ok single line: '2'

Test #13:

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

input:

3
2
3
1

output:

2

result:

ok single line: '2'

Test #14:

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

input:

3
3
1
2

output:

2

result:

ok single line: '2'

Test #15:

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

input:

3
3
2
1

output:

2

result:

ok single line: '2'

Test #16:

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

input:

4
1
2
3
4

output:

3

result:

ok single line: '3'

Test #17:

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

input:

4
1
2
4
3

output:

3

result:

ok single line: '3'

Test #18:

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

input:

4
1
3
2
4

output:

3

result:

ok single line: '3'

Test #19:

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

input:

4
1
3
4
2

output:

3

result:

ok single line: '3'

Test #20:

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

input:

4
1
4
2
3

output:

3

result:

ok single line: '3'

Test #21:

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

input:

4
1
4
3
2

output:

3

result:

ok single line: '3'

Test #22:

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

input:

4
2
1
3
4

output:

3

result:

ok single line: '3'

Test #23:

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

input:

4
2
1
4
3

output:

3

result:

ok single line: '3'

Test #24:

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

input:

4
2
3
1
4

output:

3

result:

ok single line: '3'

Test #25:

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

input:

4
2
3
4
1

output:

3

result:

ok single line: '3'

Test #26:

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

input:

4
2
4
1
3

output:

3

result:

ok single line: '3'

Test #27:

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

input:

4
2
4
3
1

output:

3

result:

ok single line: '3'

Test #28:

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

input:

4
3
1
2
4

output:

3

result:

ok single line: '3'

Test #29:

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

input:

4
3
1
4
2

output:

3

result:

ok single line: '3'

Test #30:

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

input:

4
3
2
1
4

output:

3

result:

ok single line: '3'

Test #31:

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

input:

4
3
2
4
1

output:

3

result:

ok single line: '3'

Test #32:

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

input:

4
3
4
1
2

output:

3

result:

ok single line: '3'

Test #33:

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

input:

4
3
4
2
1

output:

3

result:

ok single line: '3'

Test #34:

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

input:

4
4
1
2
3

output:

3

result:

ok single line: '3'

Test #35:

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

input:

4
4
1
3
2

output:

3

result:

ok single line: '3'

Test #36:

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

input:

4
4
2
1
3

output:

3

result:

ok single line: '3'

Test #37:

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

input:

4
4
2
3
1

output:

3

result:

ok single line: '3'

Test #38:

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

input:

4
4
3
1
2

output:

3

result:

ok single line: '3'

Test #39:

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

input:

4
4
3
2
1

output:

3

result:

ok single line: '3'

Test #40:

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

input:

5
1
2
3
4
5

output:

4

result:

ok single line: '4'

Test #41:

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

input:

5
1
2
3
5
4

output:

4

result:

ok single line: '4'

Test #42:

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

input:

5
1
2
4
3
5

output:

4

result:

ok single line: '4'

Test #43:

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

input:

5
1
2
4
5
3

output:

4

result:

ok single line: '4'

Test #44:

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

input:

5
1
2
5
3
4

output:

4

result:

ok single line: '4'

Test #45:

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

input:

5
1
2
5
4
3

output:

4

result:

ok single line: '4'

Test #46:

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

input:

5
1
3
2
4
5

output:

4

result:

ok single line: '4'

Test #47:

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

input:

5
1
3
2
5
4

output:

3

result:

ok single line: '3'

Test #48:

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

input:

5
1
3
4
2
5

output:

4

result:

ok single line: '4'

Test #49:

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

input:

5
1
3
4
5
2

output:

4

result:

ok single line: '4'

Test #50:

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

input:

5
1
3
5
2
4

output:

4

result:

ok single line: '4'

Test #51:

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

input:

5
1
3
5
4
2

output:

4

result:

ok single line: '4'

Test #52:

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

input:

5
1
4
2
3
5

output:

4

result:

ok single line: '4'

Test #53:

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

input:

5
1
4
2
5
3

output:

3

result:

ok single line: '3'

Test #54:

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

input:

5
1
4
3
2
5

output:

4

result:

ok single line: '4'

Test #55:

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

input:

5
1
4
3
5
2

output:

3

result:

ok single line: '3'

Test #56:

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

input:

5
1
4
5
2
3

output:

4

result:

ok single line: '4'

Test #57:

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

input:

5
1
4
5
3
2

output:

4

result:

ok single line: '4'

Test #58:

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

input:

5
1
5
2
3
4

output:

4

result:

ok single line: '4'

Test #59:

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

input:

5
1
5
2
4
3

output:

3

result:

ok single line: '3'

Test #60:

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

input:

5
1
5
3
2
4

output:

4

result:

ok single line: '4'

Test #61:

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

input:

5
1
5
3
4
2

output:

3

result:

ok single line: '3'

Test #62:

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

input:

5
1
5
4
2
3

output:

4

result:

ok single line: '4'

Test #63:

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

input:

5
1
5
4
3
2

output:

4

result:

ok single line: '4'

Test #64:

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

input:

5
2
1
3
4
5

output:

4

result:

ok single line: '4'

Test #65:

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

input:

5
2
1
3
5
4

output:

4

result:

ok single line: '4'

Test #66:

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

input:

5
2
1
4
3
5

output:

4

result:

ok single line: '4'

Test #67:

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

input:

5
2
1
4
5
3

output:

4

result:

ok single line: '4'

Test #68:

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

input:

5
2
1
5
3
4

output:

4

result:

ok single line: '4'

Test #69:

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

input:

5
2
1
5
4
3

output:

4

result:

ok single line: '4'

Test #70:

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

input:

5
2
3
1
4
5

output:

4

result:

ok single line: '4'

Test #71:

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

input:

5
2
3
1
5
4

output:

3

result:

ok single line: '3'

Test #72:

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

input:

5
2
3
4
1
5

output:

4

result:

ok single line: '4'

Test #73:

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

input:

5
2
3
4
5
1

output:

4

result:

ok single line: '4'

Test #74:

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

input:

5
2
3
5
1
4

output:

4

result:

ok single line: '4'

Test #75:

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

input:

5
2
3
5
4
1

output:

4

result:

ok single line: '4'

Test #76:

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

input:

5
2
4
1
3
5

output:

4

result:

ok single line: '4'

Test #77:

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

input:

5
2
4
1
5
3

output:

3

result:

ok single line: '3'

Test #78:

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

input:

5
2
4
3
1
5

output:

4

result:

ok single line: '4'

Test #79:

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

input:

5
2
4
3
5
1

output:

3

result:

ok single line: '3'

Test #80:

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

input:

5
2
4
5
1
3

output:

4

result:

ok single line: '4'

Test #81:

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

input:

5
2
4
5
3
1

output:

4

result:

ok single line: '4'

Test #82:

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

input:

5
2
5
1
3
4

output:

4

result:

ok single line: '4'

Test #83:

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

input:

5
2
5
1
4
3

output:

3

result:

ok single line: '3'

Test #84:

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

input:

5
2
5
3
1
4

output:

4

result:

ok single line: '4'

Test #85:

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

input:

5
2
5
3
4
1

output:

3

result:

ok single line: '3'

Test #86:

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

input:

5
2
5
4
1
3

output:

4

result:

ok single line: '4'

Test #87:

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

input:

5
2
5
4
3
1

output:

4

result:

ok single line: '4'

Test #88:

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

input:

5
3
1
2
4
5

output:

4

result:

ok single line: '4'

Test #89:

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

input:

5
3
1
2
5
4

output:

4

result:

ok single line: '4'

Test #90:

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

input:

5
3
1
4
2
5

output:

4

result:

ok single line: '4'

Test #91:

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

input:

5
3
1
4
5
2

output:

4

result:

ok single line: '4'

Test #92:

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

input:

5
3
1
5
2
4

output:

4

result:

ok single line: '4'

Test #93:

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

input:

5
3
1
5
4
2

output:

4

result:

ok single line: '4'

Test #94:

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

input:

5
3
2
1
4
5

output:

4

result:

ok single line: '4'

Test #95:

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

input:

5
3
2
1
5
4

output:

4

result:

ok single line: '4'

Test #96:

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

input:

5
3
2
4
1
5

output:

4

result:

ok single line: '4'

Test #97:

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

input:

5
3
2
4
5
1

output:

4

result:

ok single line: '4'

Test #98:

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

input:

5
3
2
5
1
4

output:

4

result:

ok single line: '4'

Test #99:

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

input:

5
3
2
5
4
1

output:

4

result:

ok single line: '4'

Test #100:

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

input:

5
3
4
1
2
5

output:

4

result:

ok single line: '4'

Test #101:

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

input:

5
3
4
1
5
2

output:

3

result:

ok single line: '3'

Test #102:

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

input:

5
3
4
2
1
5

output:

4

result:

ok single line: '4'

Test #103:

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

input:

5
3
4
2
5
1

output:

3

result:

ok single line: '3'

Test #104:

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

input:

5
3
4
5
1
2

output:

4

result:

ok single line: '4'

Test #105:

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

input:

5
3
4
5
2
1

output:

4

result:

ok single line: '4'

Test #106:

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

input:

5
3
5
1
2
4

output:

4

result:

ok single line: '4'

Test #107:

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

input:

5
3
5
1
4
2

output:

3

result:

ok single line: '3'

Test #108:

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

input:

5
3
5
2
1
4

output:

4

result:

ok single line: '4'

Test #109:

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

input:

5
3
5
2
4
1

output:

3

result:

ok single line: '3'

Test #110:

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

input:

5
3
5
4
1
2

output:

4

result:

ok single line: '4'

Test #111:

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

input:

5
3
5
4
2
1

output:

4

result:

ok single line: '4'

Test #112:

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

input:

5
4
1
2
3
5

output:

4

result:

ok single line: '4'

Test #113:

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

input:

5
4
1
2
5
3

output:

4

result:

ok single line: '4'

Test #114:

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

input:

5
4
1
3
2
5

output:

4

result:

ok single line: '4'

Test #115:

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

input:

5
4
1
3
5
2

output:

4

result:

ok single line: '4'

Test #116:

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

input:

5
4
1
5
2
3

output:

4

result:

ok single line: '4'

Test #117:

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

input:

5
4
1
5
3
2

output:

4

result:

ok single line: '4'

Test #118:

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

input:

5
4
2
1
3
5

output:

4

result:

ok single line: '4'

Test #119:

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

input:

5
4
2
1
5
3

output:

4

result:

ok single line: '4'

Test #120:

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

input:

5
4
2
3
1
5

output:

4

result:

ok single line: '4'

Test #121:

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

input:

5
4
2
3
5
1

output:

4

result:

ok single line: '4'

Test #122:

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

input:

5
4
2
5
1
3

output:

4

result:

ok single line: '4'

Test #123:

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

input:

5
4
2
5
3
1

output:

4

result:

ok single line: '4'

Test #124:

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

input:

5
4
3
1
2
5

output:

4

result:

ok single line: '4'

Test #125:

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

input:

5
4
3
1
5
2

output:

4

result:

ok single line: '4'

Test #126:

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

input:

5
4
3
2
1
5

output:

4

result:

ok single line: '4'

Test #127:

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

input:

5
4
3
2
5
1

output:

4

result:

ok single line: '4'

Test #128:

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

input:

5
4
3
5
1
2

output:

4

result:

ok single line: '4'

Test #129:

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

input:

5
4
3
5
2
1

output:

4

result:

ok single line: '4'

Test #130:

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

input:

5
4
5
1
2
3

output:

4

result:

ok single line: '4'

Test #131:

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

input:

5
4
5
1
3
2

output:

3

result:

ok single line: '3'

Test #132:

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

input:

5
4
5
2
1
3

output:

4

result:

ok single line: '4'

Test #133:

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

input:

5
4
5
2
3
1

output:

3

result:

ok single line: '3'

Test #134:

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

input:

5
4
5
3
1
2

output:

4

result:

ok single line: '4'

Test #135:

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

input:

5
4
5
3
2
1

output:

4

result:

ok single line: '4'

Test #136:

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

input:

5
5
1
2
3
4

output:

4

result:

ok single line: '4'

Test #137:

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

input:

5
5
1
2
4
3

output:

4

result:

ok single line: '4'

Test #138:

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

input:

5
5
1
3
2
4

output:

4

result:

ok single line: '4'

Test #139:

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

input:

5
5
1
3
4
2

output:

4

result:

ok single line: '4'

Test #140:

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

input:

5
5
1
4
2
3

output:

4

result:

ok single line: '4'

Test #141:

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

input:

5
5
1
4
3
2

output:

4

result:

ok single line: '4'

Test #142:

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

input:

5
5
2
1
3
4

output:

4

result:

ok single line: '4'

Test #143:

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

input:

5
5
2
1
4
3

output:

4

result:

ok single line: '4'

Test #144:

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

input:

5
5
2
3
1
4

output:

4

result:

ok single line: '4'

Test #145:

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

input:

5
5
2
3
4
1

output:

4

result:

ok single line: '4'

Test #146:

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

input:

5
5
2
4
1
3

output:

4

result:

ok single line: '4'

Test #147:

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

input:

5
5
2
4
3
1

output:

4

result:

ok single line: '4'

Test #148:

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

input:

5
5
3
1
2
4

output:

4

result:

ok single line: '4'

Test #149:

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

input:

5
5
3
1
4
2

output:

4

result:

ok single line: '4'

Test #150:

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

input:

5
5
3
2
1
4

output:

4

result:

ok single line: '4'

Test #151:

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

input:

5
5
3
2
4
1

output:

4

result:

ok single line: '4'

Test #152:

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

input:

5
5
3
4
1
2

output:

4

result:

ok single line: '4'

Test #153:

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

input:

5
5
3
4
2
1

output:

4

result:

ok single line: '4'

Test #154:

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

input:

5
5
4
1
2
3

output:

4

result:

ok single line: '4'

Test #155:

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

input:

5
5
4
1
3
2

output:

4

result:

ok single line: '4'

Test #156:

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

input:

5
5
4
2
1
3

output:

4

result:

ok single line: '4'

Test #157:

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

input:

5
5
4
2
3
1

output:

4

result:

ok single line: '4'

Test #158:

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

input:

5
5
4
3
1
2

output:

4

result:

ok single line: '4'

Test #159:

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

input:

5
5
4
3
2
1

output:

4

result:

ok single line: '4'

Test #160:

score: 0
Accepted
time: 1171ms
memory: 109740kb

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: 1172ms
memory: 109744kb

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: 1182ms
memory: 109768kb

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: 1185ms
memory: 109744kb

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'