QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#489118#8811. Heat StrokeCrying95 1400ms1005664kbC++142.9kb2024-07-24 18:13:112024-07-24 18:13:12

Judging History

This is the latest submission verdict.

  • [2024-07-24 18:13:12]
  • Judged
  • Verdict: 95
  • Time: 1400ms
  • Memory: 1005664kb
  • [2024-07-24 18:13:11]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 8010,INF = 1e9;
template<typename T>void tomin(T& x,T y){x = min(x,y);}
template<typename T>void tomax(T& x,T y){x = max(x,y);}
//
int n,m,c[MAXN],sum[MAXN][MAXN],all[MAXN],arr[MAXN][MAXN],len[MAXN];

int f[2][MAXN][MAXN],g[2],ans;

int val_a[MAXN];

int main(){
    cin>>n; for(int i=1;i<=n;i++)cin>>c[i],arr[i][++len[i]] = 0;
    cin>>m; for(int i=1,p;i<=m;i++){
        cin>>p;
        sum[p][i]++; all[p]++;
        if(i<m)arr[p][++len[p]] = arr[p+1][++len[p+1]] = i;
    } 
    for(int i=1;i<n;i++)for(int j=1;j<=m;j++)sum[i][j] += sum[i][j-1];
    for(int i=1;i<=n;i++)arr[i][++len[i]] = m; arr[0][++len[0]] = m;

    for(int i=0;i<2;i++)for(int j=0;j<m;j++)for(int k=0;k<=m;k++)f[i][j][k] = -INF; g[0] = g[1] = -INF;
    g[0] = 0;
    for(int i=1;i<=n;i++){
        int p = (i-1)&1,q = i&1; 
        //f -> f
        for(int S=0;S<=m;S++)val_a[S] = -INF;
        int cur = len[i-1]-1;
        for(int jd=len[i]-1;jd>=1;jd--){
            int y = arr[i][jd];
            while(cur && arr[i-1][cur] >= y){
                int x = arr[i-1][cur--];
                for(int S=0;S<=m;S++){
                    int w = f[p][x][S]; if(w == -INF)continue; 
                    w += all[i-1] - sum[i-1][x];
                    tomax(val_a[S],w);
                }
            }
            int vx = sum[i-1][y] + sum[i][y] - c[i],vy = sum[i][y] - c[i];
            for(int S=m;S>=0;S--){
                int nk = min(vx,vy+S); if(nk<0)break;
                tomax(f[q][y][nk],val_a[S]);
            }
        }

        for(int id=1;id<len[i-1];id++){
            int x = arr[i-1][id];
            for(int S=0;S<=m;S++){
                int& w = f[p][x][S]; if(w == -INF)continue;
                for(int jd=len[i]-1;jd>=1;jd--){
                    int y = arr[i][jd]; if(x>=y)break;
                    int nw = w + all[i-1] - sum[i-1][y];
                    int vx = sum[i-1][y] + sum[i][y] - c[i];
                    int vy = sum[i][y] - c[i] + sum[i-1][y] - sum[i-1][x];
                    int nk = min(vx,S + vy); 
                    if(nk < 0)continue;
                    tomax(f[q][y][nk],nw);
                }
            }
        }
        //f -> g
        for(int id=1;id<len[i-1];id++){
            int j = arr[i-1][id];
            for(int k=0;k<=m;k++){
                int& w = f[p][j][k]; if(w == -INF)continue;
                tomax(g[q],w);
                w = -INF;
            }
        }
        //g -> f
        for(int id=1;id<len[i];id++){
            int j = arr[i][id],vx = sum[i-1][j] + sum[i][j] - c[i];
            if(vx < 0)continue;
            tomax(f[q][j][vx],g[p]);
        }
        //g -> g
        tomax(g[q],g[p]);
        g[p] = -INF;
    }
    tomax(ans,g[n&1]); for(int j=0;j<m;j++)for(int k=0;k<=m;k++)tomax(ans,f[n&1][j][k]);
    cout<<ans<<endl;
    return 0;
}

詳細信息

Subtask #1:

score: 6
Accepted

Test #1:

score: 6
Accepted
time: 1ms
memory: 7676kb

input:

2
0 0
1
1

output:

1

result:

ok single line: '1'

Test #2:

score: 6
Accepted
time: 1ms
memory: 9792kb

input:

2
0 1
1
1

output:

0

result:

ok single line: '0'

Test #3:

score: 6
Accepted
time: 1ms
memory: 7724kb

input:

2
1 0
1
1

output:

0

result:

ok single line: '0'

Test #4:

score: 6
Accepted
time: 1ms
memory: 7728kb

input:

2
1 1
1
1

output:

0

result:

ok single line: '0'

Test #5:

score: 6
Accepted
time: 1ms
memory: 7624kb

input:

2
2 2
1
1

output:

0

result:

ok single line: '0'

Test #6:

score: 6
Accepted
time: 1ms
memory: 7724kb

input:

2
1 1
2
1 1

output:

0

result:

ok single line: '0'

Test #7:

score: 6
Accepted
time: 1ms
memory: 7744kb

input:

2
2 2
2
1 1

output:

0

result:

ok single line: '0'

Test #8:

score: 6
Accepted
time: 1ms
memory: 9712kb

input:

2
3 3
2
1 1

output:

0

result:

ok single line: '0'

Test #9:

score: 6
Accepted
time: 3ms
memory: 44760kb

input:

2
298 299
600
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

3

result:

ok single line: '3'

Test #10:

score: 6
Accepted
time: 72ms
memory: 227456kb

input:

2
1749 1749
3500
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

2

result:

ok single line: '2'

Test #11:

score: 6
Accepted
time: 361ms
memory: 506708kb

input:

2
3999 3999
8000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

2

result:

ok single line: '2'

Test #12:

score: 6
Accepted
time: 582ms
memory: 506780kb

input:

2
1 1
8000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

7998

result:

ok single line: '7998'

Test #13:

score: 6
Accepted
time: 590ms
memory: 508772kb

input:

2
0 0
8000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

8000

result:

ok single line: '8000'

Test #14:

score: 6
Accepted
time: 1ms
memory: 7756kb

input:

3
0 1 1
2
1 2

output:

0

result:

ok single line: '0'

Test #15:

score: 6
Accepted
time: 1ms
memory: 7736kb

input:

3
1 1 1
3
1 2 2

output:

1

result:

ok single line: '1'

Test #16:

score: 6
Accepted
time: 1ms
memory: 7752kb

input:

3
1 2 0
3
1 1 2

output:

1

result:

ok single line: '1'

Test #17:

score: 6
Accepted
time: 1ms
memory: 7668kb

input:

3
1 2 0
3
1 2 2

output:

1

result:

ok single line: '1'

Test #18:

score: 6
Accepted
time: 1ms
memory: 9784kb

input:

3
1 3 0
4
1 1 1 2

output:

1

result:

ok single line: '1'

Test #19:

score: 6
Accepted
time: 1ms
memory: 7748kb

input:

4
0 2 1 1
4
1 1 2 3

output:

0

result:

ok single line: '0'

Test #20:

score: 6
Accepted
time: 1ms
memory: 12016kb

input:

18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
33
1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17

output:

15

result:

ok single line: '15'

Test #21:

score: 6
Accepted
time: 268ms
memory: 724196kb

input:

8000
0 2 0 0 0 0 0 0 1 0 0 2 1 1 0 1 1 0 2 2 0 0 0 1 1 0 0 0 0 1 1 1 2 3 0 2 2 0 0 1 0 1 2 1 1 0 1 1 0 0 0 0 1 1 0 1 0 0 0 1 1 0 0 1 0 1 0 0 0 0 0 0 1 0 0 0 1 0 1 2 0 0 0 0 0 1 0 1 1 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 2 2 0 3 2 0 0 0 0 0 1 1 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 1 1 0 0 1 0 0 0 0 0 1 3 0...

output:

843

result:

ok single line: '843'

Test #22:

score: 6
Accepted
time: 938ms
memory: 1005664kb

input:

8000
1 0 1 2 3 2 1 1 1 1 2 4 1 3 2 2 0 3 2 0 1 1 1 1 0 0 0 0 1 0 4 4 3 0 0 0 2 1 0 0 0 0 0 0 0 0 0 2 0 3 3 0 2 0 0 0 2 0 0 2 2 0 1 5 3 0 0 3 0 1 1 2 1 1 2 2 0 0 3 0 0 1 0 0 1 0 1 1 2 3 0 0 1 4 1 2 1 1 2 1 0 0 0 2 2 1 1 0 1 1 1 1 1 0 0 0 0 0 1 0 1 0 3 0 1 1 0 1 1 1 0 0 2 1 1 3 3 0 1 0 0 4 1 0 0 1 0 0...

output:

1799

result:

ok single line: '1799'

Test #23:

score: 6
Accepted
time: 939ms
memory: 1004768kb

input:

8000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

2146

result:

ok single line: '2146'

Test #24:

score: 6
Accepted
time: 639ms
memory: 1004196kb

input:

8000
8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 ...

output:

0

result:

ok single line: '0'

Test #25:

score: 6
Accepted
time: 735ms
memory: 730188kb

input:

3579
0 3 5 0 3 0 1 6 5 1 1 7 0 1 2 0 0 4 3 1 0 4 2 8 2 5 2 2 3 2 0 0 1 4 2 2 2 4 2 0 4 1 0 4 0 5 3 4 1 8 6 0 0 0 2 4 1 2 7 8 2 2 3 5 0 1 0 0 2 1 4 6 4 4 1 1 4 2 1 0 3 3 0 4 4 1 1 6 0 1 2 0 0 1 3 7 3 2 1 3 2 2 1 0 0 0 1 5 4 4 3 0 3 4 4 3 2 1 2 2 1 1 2 1 1 3 11 1 2 0 3 0 4 1 3 3 6 2 1 7 6 2 0 1 3 0 1 ...

output:

1634

result:

ok single line: '1634'

Test #26:

score: 6
Accepted
time: 641ms
memory: 590864kb

input:

1357
11 16 5 0 6 10 10 7 5 1 12 13 4 9 4 6 0 6 1 11 2 8 7 8 1 4 8 9 3 3 3 4 1 4 4 1 5 6 18 7 10 6 9 7 10 2 10 6 1 2 4 12 9 5 7 5 4 5 1 4 4 6 1 4 11 3 13 3 12 7 0 3 9 1 5 6 3 2 3 0 13 2 8 1 6 10 4 5 15 1 1 1 2 5 7 8 5 11 3 7 4 2 0 7 3 6 6 0 3 1 5 4 13 13 5 5 0 6 1 7 9 1 8 1 6 8 12 2 2 2 5 8 11 5 7 6 ...

output:

1608

result:

ok single line: '1608'

Test #27:

score: 6
Accepted
time: 583ms
memory: 510744kb

input:

68
38 219 171 204 116 205 90 225 221 43 74 153 142 147 151 133 65 189 196 4 91 93 215 80 213 25 180 16 24 143 60 22 129 190 59 70 242 53 205 95 212 26 69 123 50 47 205 5 62 154 78 203 48 99 118 7 25 151 222 141 151 143 90 90 141 228 193 75
8000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

1018

result:

ok single line: '1018'

Test #28:

score: 6
Accepted
time: 544ms
memory: 506768kb

input:

3
137 4887 1630
8000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

1483

result:

ok single line: '1483'

Test #29:

score: 6
Accepted
time: 628ms
memory: 506760kb

input:

3
1 7999 0
8000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

1

result:

ok single line: '1'

Test #30:

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

input:

4
0 50 50 0
100
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2

output:

0

result:

ok single line: '0'

Test #31:

score: 6
Accepted
time: 612ms
memory: 506784kb

input:

4
0 4000 4000 0
8000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

0

result:

ok single line: '0'

Test #32:

score: 6
Accepted
time: 542ms
memory: 534860kb

input:

800
0 0 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 0 10 0 11 0 12 0 13 0 14 0 15 0 16 0 17 0 18 0 19 1 0 1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 2 0 2 1 2 2 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 3 0 3 1 3 2 3 3 3 4 3 5 3 ...

output:

1330

result:

ok single line: '1330'

Subtask #2:

score: 7
Accepted

Test #33:

score: 7
Accepted
time: 1ms
memory: 7612kb

input:

3
1 1 1
3
1 2 1

output:

1

result:

ok single line: '1'

Test #34:

score: 7
Accepted
time: 1ms
memory: 7824kb

input:

3
1 1 1
3
2 1 2

output:

1

result:

ok single line: '1'

Test #35:

score: 7
Accepted
time: 1ms
memory: 9868kb

input:

7
1 1 1 1 1 1 1
8
2 1 6 5 4 3 2 6

output:

3

result:

ok single line: '3'

Test #36:

score: 7
Accepted
time: 1ms
memory: 7720kb

input:

8
1 1 1 1 1 1 1 1
10
6 7 4 1 2 3 4 5 6 1

output:

4

result:

ok single line: '4'

Test #37:

score: 7
Accepted
time: 1ms
memory: 7864kb

input:

18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
13
13 17 13 9 15 4 12 11 12 7 5 15 1

output:

1

result:

ok single line: '1'

Test #38:

score: 7
Accepted
time: 1ms
memory: 12020kb

input:

18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
15
17 12 6 3 15 17 3 10 6 12 15 17 11 12 14

output:

3

result:

ok single line: '3'

Test #39:

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

input:

18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
16
16 11 13 10 5 3 10 6 13 16 16 2 14 9 9 3

output:

4

result:

ok single line: '4'

Test #40:

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

input:

18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
17
12 5 4 1 10 6 8 8 16 6 12 14 7 14 17 12 9

output:

4

result:

ok single line: '4'

Test #41:

score: 7
Accepted
time: 1ms
memory: 7760kb

input:

18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
18
14 9 3 16 9 2 2 9 4 10 12 17 13 10 10 10 3 11

output:

7

result:

ok single line: '7'

Test #42:

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

input:

17
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
18
15 9 6 3 13 9 13 16 7 5 8 1 1 9 9 15 16 1

output:

5

result:

ok single line: '5'

Test #43:

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

input:

16
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
18
13 4 8 8 13 8 1 15 3 6 4 8 6 4 12 9 15 14

output:

5

result:

ok single line: '5'

Test #44:

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

input:

15
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
18
1 10 3 3 9 6 4 8 3 12 12 11 7 14 6 5 3 3

output:

6

result:

ok single line: '6'

Test #45:

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

input:

13
1 1 1 1 1 1 1 1 1 1 1 1 1
18
11 5 4 8 12 2 1 3 8 8 9 4 12 7 12 3 6 6

output:

7

result:

ok single line: '7'

Test #46:

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

input:

13
1 1 1 1 1 1 1 1 1 1 1 1 1
18
1 2 1 3 4 3 5 6 5 7 8 7 9 10 9 11 12 11

output:

6

result:

ok single line: '6'

Test #47:

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

input:

18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
18
1 5 7 11 13 17 2 4 8 10 14 16 1 5 7 11 13 17

output:

6

result:

ok single line: '6'

Test #48:

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

input:

16
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
15
1 3 2 4 6 5 7 9 8 10 12 11 13 15 14

output:

5

result:

ok single line: '5'

Test #49:

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

input:

18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
18
1 1 2 4 5 4 7 8 8 11 10 10 14 13 14 17 17 16

output:

4

result:

ok single line: '4'

Test #50:

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

input:

16
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
12
1 2 3 5 7 6 10 9 11 15 14 13

output:

1

result:

ok single line: '1'

Subtask #3:

score: 7
Accepted

Dependency #2:

100%
Accepted

Test #51:

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

input:

18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
33
17 17 16 16 15 15 14 14 13 13 12 12 11 11 10 10 9 9 8 8 7 7 6 6 5 5 4 4 3 3 2 2 1

output:

15

result:

ok single line: '15'

Test #52:

score: 7
Accepted
time: 1ms
memory: 11880kb

input:

18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
20
16 6 17 10 14 2 12 6 12 16 9 16 1 1 8 16 15 1 5 6

output:

7

result:

ok single line: '7'

Test #53:

score: 7
Accepted
time: 1ms
memory: 9936kb

input:

18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
23
6 4 16 11 16 17 7 15 7 14 11 16 16 17 17 17 15 15 17 12 5 14 7

output:

11

result:

ok single line: '11'

Test #54:

score: 7
Accepted
time: 1ms
memory: 9956kb

input:

18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
26
1 1 11 15 12 16 15 5 12 12 10 10 5 3 12 11 8 15 12 8 7 10 3 4 15 15

output:

11

result:

ok single line: '11'

Test #55:

score: 7
Accepted
time: 1ms
memory: 9952kb

input:

18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
29
5 14 2 14 12 11 1 6 13 9 14 1 16 1 2 16 11 3 6 3 12 6 16 8 7 3 15 6 2

output:

14

result:

ok single line: '14'

Test #56:

score: 7
Accepted
time: 1ms
memory: 9944kb

input:

18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
32
10 14 1 6 9 8 3 12 4 2 16 5 14 13 13 6 3 13 11 13 8 1 15 13 2 3 8 14 13 1 15 9

output:

18

result:

ok single line: '18'

Test #57:

score: 7
Accepted
time: 1ms
memory: 10000kb

input:

18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
35
3 9 4 14 11 1 2 4 6 14 12 7 8 14 11 15 7 10 2 9 2 3 11 3 2 7 3 5 16 3 3 11 9 17 12

output:

18

result:

ok single line: '18'

Test #58:

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

input:

18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
38
7 14 9 15 8 7 6 6 10 15 10 16 6 13 11 8 15 11 12 16 2 5 13 10 3 4 14 4 12 8 8 17 11 5 9 5 12 16

output:

22

result:

ok single line: '22'

Test #59:

score: 7
Accepted
time: 1ms
memory: 11892kb

input:

18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
41
15 16 17 13 2 16 3 2 10 3 16 11 9 13 1 3 16 2 3 17 10 12 8 2 9 2 8 17 4 8 10 1 1 13 7 6 14 13 2 9 1

output:

23

result:

ok single line: '23'

Test #60:

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

input:

18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
100
3 1 15 2 12 2 12 16 8 6 9 14 15 16 17 13 8 8 9 14 17 8 17 2 3 14 3 10 17 7 11 1 17 1 17 9 14 6 1 2 6 9 7 11 7 6 15 9 4 14 10 3 17 15 14 4 8 16 10 11 15 9 15 17 15 7 12 7 7 4 9 4 14 14 6 14 10 7 15 7 14 4 1 5 17 4 3 4 8 4 1 7 9 1 7 9 12 9 17 2

output:

82

result:

ok single line: '82'

Test #61:

score: 7
Accepted
time: 1ms
memory: 9928kb

input:

17
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
24
1 2 1 3 4 3 5 6 5 7 8 7 9 10 9 11 12 11 13 14 13 15 16 15

output:

8

result:

ok single line: '8'

Test #62:

score: 7
Accepted
time: 1ms
memory: 11816kb

input:

18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
32
2 1 3 2 4 3 5 4 6 5 7 6 8 7 9 8 10 9 11 10 12 11 13 12 14 13 15 14 16 15 17 16

output:

15

result:

ok single line: '15'

Test #63:

score: 7
Accepted
time: 1ms
memory: 9964kb

input:

18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
32
2 16 1 17 3 15 2 16 4 14 3 15 5 13 4 14 6 12 5 13 7 11 6 12 8 10 7 11 9 8 10 9

output:

16

result:

ok single line: '16'

Test #64:

score: 7
Accepted
time: 1ms
memory: 12032kb

input:

18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
32
9 10 8 9 11 7 10 8 12 6 11 7 13 5 12 6 14 4 13 5 15 3 14 4 16 2 15 3 17 1 16 2

output:

15

result:

ok single line: '15'

Test #65:

score: 7
Accepted
time: 1ms
memory: 9956kb

input:

18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
32
9 10 8 9 11 7 10 8 12 6 11 7 13 5 12 6 14 4 13 5 15 3 14 4 1 16 2 15 3 17 16 2

output:

16

result:

ok single line: '16'

Test #66:

score: 7
Accepted
time: 1ms
memory: 12020kb

input:

18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
32
1 17 2 16 3 15 4 14 5 13 6 12 7 11 8 10 9 1 17 2 16 3 15 4 14 5 13 6 12 7 11 8

output:

15

result:

ok single line: '15'

Subtask #4:

score: 25
Accepted

Dependency #3:

100%
Accepted

Test #67:

score: 25
Accepted
time: 2ms
memory: 16116kb

input:

100
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
50
10 18 8 18 88 37 61 48 39 35 74 58 24 43 99 70 8 9 48 88 26 30 26 37 99 29 25 1 57 34 40 98 2...

output:

7

result:

ok single line: '7'

Test #68:

score: 25
Accepted
time: 0ms
memory: 16220kb

input:

100
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
60
28 72 39 42 9 65 38 46 4 19 69 70 94 31 20 55 9 42 54 72 49 20 71 38 34 14 22 94 16 26 5 55 8...

output:

12

result:

ok single line: '12'

Test #69:

score: 25
Accepted
time: 0ms
memory: 18172kb

input:

100
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
70
73 38 10 32 90 75 51 10 58 68 78 88 19 1 25 90 31 42 53 17 90 19 35 90 24 18 88 71 66 73 54 8...

output:

12

result:

ok single line: '12'

Test #70:

score: 25
Accepted
time: 0ms
memory: 22308kb

input:

100
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
80
3 56 58 99 25 30 32 62 45 58 15 95 6 45 13 21 89 45 14 65 13 6 35 30 31 52 93 55 66 83 4 79 7...

output:

20

result:

ok single line: '20'

Test #71:

score: 25
Accepted
time: 0ms
memory: 20328kb

input:

100
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
90
8 76 98 17 85 41 9 75 61 79 57 50 59 43 80 80 23 57 89 64 13 49 93 14 50 1 46 47 85 78 87 3 9...

output:

26

result:

ok single line: '26'

Test #72:

score: 25
Accepted
time: 0ms
memory: 20244kb

input:

100
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
100
74 8 70 56 3 97 4 87 6 56 3 57 38 67 79 58 13 48 18 89 5 59 34 21 79 59 29 58 86 19 42 95 79...

output:

33

result:

ok single line: '33'

Test #73:

score: 25
Accepted
time: 2ms
memory: 18320kb

input:

90
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
100
27 4 2 53 45 51 18 68 73 22 4 15 15 75 82 16 24 34 77 13 85 9 40 40 71 7 55 17 61 72 40 43 57 49 84 28 85 25 44 8...

output:

33

result:

ok single line: '33'

Test #74:

score: 25
Accepted
time: 2ms
memory: 18320kb

input:

80
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
100
69 58 66 69 2 32 59 79 2 47 56 40 1 79 77 62 56 45 34 32 14 19 44 19 18 65 9 74 47 47 78 24 35 8 3 73 56 9 38 17 10 47 11 67 36 18 34...

output:

38

result:

ok single line: '38'

Test #75:

score: 25
Accepted
time: 2ms
memory: 20348kb

input:

70
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
100
41 3 68 43 52 67 22 16 8 56 7 64 32 61 16 33 36 49 30 32 29 13 37 46 3 12 37 67 59 60 64 37 69 61 30 68 28 37 66 42 3 32 49 6 26 27 50 68 58 56 43 60 8 6...

output:

41

result:

ok single line: '41'

Test #76:

score: 25
Accepted
time: 2ms
memory: 16172kb

input:

60
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
100
14 42 8 9 22 15 22 15 59 59 5 12 44 38 26 35 2 4 38 25 17 48 1 7 23 15 18 41 30 59 42 4 3 40 29 25 26 57 45 28 51 25 49 1 52 49 59 51 1 34 32 38 13 29 53 16 1 11 6 59 53 8 3...

output:

49

result:

ok single line: '49'

Test #77:

score: 25
Accepted
time: 0ms
memory: 18112kb

input:

50
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
100
44 32 27 37 12 4 35 2 17 12 13 17 15 48 49 34 12 46 26 16 5 22 15 40 12 13 22 25 24 13 17 49 27 36 5 17 41 35 16 22 2 38 11 25 37 4 17 18 48 23 31 39 44 3 37 29 44 45 1 36 2 6 49 3 5 24 40 41 2...

output:

54

result:

ok single line: '54'

Test #78:

score: 25
Accepted
time: 0ms
memory: 18452kb

input:

67
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
99
1 2 1 3 4 3 5 6 5 7 8 7 9 10 9 11 12 11 13 14 13 15 16 15 17 18 17 19 20 19 21 22 21 23 24 23 25 26 25 27 28 27 29 30 29 31 32 31 33 34 33 35 36 35 37 38 37 39 ...

output:

33

result:

ok single line: '33'

Test #79:

score: 25
Accepted
time: 2ms
memory: 20288kb

input:

99
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
99
1 5 7 11 13 17 19 23 25 29 31 35 37 41 43 47 49 53 55 59 61 65 67 71 73 77 79 83 85 89 91 95 97 ...

output:

33

result:

ok single line: '33'

Test #80:

score: 25
Accepted
time: 2ms
memory: 20484kb

input:

100
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
99
1 3 2 4 6 5 7 9 8 10 12 11 13 15 14 16 18 17 19 21 20 22 24 23 25 27 26 28 30 29 31 33 32 34 ...

output:

33

result:

ok single line: '33'

Test #81:

score: 25
Accepted
time: 1ms
memory: 16040kb

input:

52
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
100
2 1 3 2 4 3 5 4 6 5 7 6 8 7 9 8 10 9 11 10 12 11 13 12 14 13 15 14 16 15 17 16 18 17 19 18 20 19 21 20 22 21 23 22 24 23 25 24 26 25 27 26 28 27 29 28 30 29 31 30 32 31 33 32 34 33 35 34 36...

output:

49

result:

ok single line: '49'

Test #82:

score: 25
Accepted
time: 0ms
memory: 18240kb

input:

52
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
100
2 50 1 51 3 49 2 50 4 48 3 49 5 47 4 48 6 46 5 47 7 45 6 46 8 44 7 45 9 43 8 44 10 42 9 43 11 41 10 42 12 40 11 41 13 39 12 40 14 38 13 39 15 37 14 38 16 36 15 37 17 35 16 36 18 34 17 35 19...

output:

50

result:

ok single line: '50'

Test #83:

score: 25
Accepted
time: 0ms
memory: 20244kb

input:

52
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
100
26 27 25 26 28 24 27 25 29 23 28 24 30 22 29 23 31 21 30 22 32 20 31 21 33 19 32 20 34 18 33 19 35 17 34 18 36 16 35 17 37 15 36 16 38 14 37 15 39 13 38 14 40 12 39 13 41 11 40 12 42 10 41 ...

output:

49

result:

ok single line: '49'

Test #84:

score: 25
Accepted
time: 0ms
memory: 16196kb

input:

52
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
100
26 27 25 26 28 24 27 25 29 23 28 24 30 22 29 23 31 21 30 22 32 20 31 21 33 19 32 20 34 18 33 19 35 17 34 18 36 16 35 17 37 15 36 16 38 14 37 15 39 13 38 14 40 12 39 13 41 11 40 12 42 10 41 ...

output:

50

result:

ok single line: '50'

Test #85:

score: 25
Accepted
time: 0ms
memory: 20304kb

input:

52
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
100
1 51 2 50 3 49 4 48 5 47 6 46 7 45 8 44 9 43 10 42 11 41 12 40 13 39 14 38 15 37 16 36 17 35 18 34 19 33 20 32 21 31 22 30 23 29 24 28 25 27 26 1 51 2 50 3 49 4 48 5 47 6 46 7 45 8 44 9 43 ...

output:

49

result:

ok single line: '49'

Test #86:

score: 25
Accepted
time: 2ms
memory: 14296kb

input:

42
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
56
1 1 1 2 4 4 5 4 7 7 8 8 10 11 10 10 13 14 13 14 16 17 17 16 19 20 20 20 23 22 22 22 26 25 25 26 29 28 29 28 32 31 32 32 35 35 34 34 38 38 37 38 41 41 41 40

output:

18

result:

ok single line: '18'

Test #87:

score: 25
Accepted
time: 0ms
memory: 19968kb

input:

84
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
84
1 1 2 3 5 5 7 6 9 10 9 11 13 14 14 15 17 18 19 18 21 22 23 23 25 27 26 25 29 31 30 30 33 35 34 35 37 39 39 38 42 41 41 43 46 4...

output:

19

result:

ok single line: '19'

Test #88:

score: 25
Accepted
time: 0ms
memory: 13952kb

input:

40
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
32
1 2 3 4 6 7 9 8 11 13 12 14 16 19 18 17 22 21 23 24 27 26 29 28 33 32 31 34 39 38 37 36

output:

4

result:

ok single line: '4'

Test #89:

score: 25
Accepted
time: 0ms
memory: 16452kb

input:

96
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
80
1 2 3 4 5 7 8 9 11 10 13 14 16 15 17 19 20 23 22 21 25 27 26 28 29 31 33 32 35 34 37 40 39 38 41 43 47...

output:

11

result:

ok single line: '11'

Subtask #5:

score: 25
Accepted

Dependency #4:

100%
Accepted

Test #90:

score: 25
Accepted
time: 1ms
memory: 7748kb

input:

3
1 1 0
2
2 1

output:

0

result:

ok single line: '0'

Test #91:

score: 25
Accepted
time: 1ms
memory: 7768kb

input:

3
0 0 0
3
1 2 1

output:

3

result:

ok single line: '3'

Test #92:

score: 25
Accepted
time: 1ms
memory: 9848kb

input:

3
0 2 1
3
2 1 1

output:

1

result:

ok single line: '1'

Test #93:

score: 25
Accepted
time: 1ms
memory: 7768kb

input:

4
1 1 2 0
4
3 3 2 1

output:

0

result:

ok single line: '0'

Test #94:

score: 25
Accepted
time: 1ms
memory: 9696kb

input:

4
1 2 2 1
5
2 2 1 3 2

output:

1

result:

ok single line: '1'

Test #95:

score: 25
Accepted
time: 1ms
memory: 9724kb

input:

4
1 2 2 1
5
3 1 2 2 2

output:

1

result:

ok single line: '1'

Test #96:

score: 25
Accepted
time: 1ms
memory: 7828kb

input:

4
1 2 2 1
5
1 3 2 2 2

output:

1

result:

ok single line: '1'

Test #97:

score: 25
Accepted
time: 0ms
memory: 7816kb

input:

4
1 2 2 0
6
2 2 3 2 1 2

output:

2

result:

ok single line: '2'

Test #98:

score: 25
Accepted
time: 1ms
memory: 7764kb

input:

4
0 2 2 1
6
2 2 1 2 3 2

output:

2

result:

ok single line: '2'

Test #99:

score: 25
Accepted
time: 0ms
memory: 18240kb

input:

100
2 0 1 1 0 2 1 0 1 0 0 0 0 0 0 0 0 1 0 1 1 1 0 0 0 0 1 0 0 2 2 3 3 0 0 0 0 0 0 1 1 0 0 0 2 2 2 0 0 0 0 2 1 0 3 3 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 1 3 3 1 0 1 1 0 0 1 1 0 1 0 0 0 1 0 0 2 0 0 0 0 1 1 2 0
60
91 70 82 1 20 65 5 76 90 55 86 6 3 52 9 55 58 89 32 43 22 85 52 72 68 32 32 46 74 31 22 26 67...

output:

18

result:

ok single line: '18'

Test #100:

score: 25
Accepted
time: 2ms
memory: 20328kb

input:

100
0 1 2 2 0 2 0 2 1 0 3 2 2 0 0 0 2 4 0 1 2 0 0 0 0 0 1 0 0 0 2 3 2 0 1 1 1 1 1 0 0 3 0 0 0 0 0 1 1 0 0 0 0 0 1 0 0 0 0 0 0 1 0 3 0 0 0 2 0 0 1 0 0 1 0 2 1 0 2 0 4 3 1 0 0 0 2 1 2 1 0 0 1 2 1 2 1 0 0 0
80
56 48 35 10 4 81 37 42 18 20 27 90 96 76 86 17 63 67 64 60 65 71 41 89 94 39 61 80 87 86 75 8...

output:

17

result:

ok single line: '17'

Test #101:

score: 25
Accepted
time: 0ms
memory: 20284kb

input:

100
3 2 0 0 1 0 1 5 3 0 0 1 2 1 3 1 0 0 3 2 0 0 0 2 2 0 0 2 1 3 0 1 0 0 0 0 1 2 0 0 0 1 0 1 1 0 1 1 0 0 2 1 0 1 0 1 1 1 2 1 3 2 0 0 2 0 1 1 0 0 1 0 1 1 2 3 2 3 1 0 1 2 2 3 1 2 1 1 1 1 1 0 0 0 0 0 2 1 1 1
100
87 85 37 97 25 85 91 97 84 21 51 61 15 19 5 27 58 73 99 81 59 56 75 38 81 47 40 29 65 99 64 ...

output:

22

result:

ok single line: '22'

Test #102:

score: 25
Accepted
time: 0ms
memory: 18436kb

input:

100
8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8...

output:

0

result:

ok single line: '0'

Test #103:

score: 25
Accepted
time: 2ms
memory: 20172kb

input:

80
0 0 1 0 0 0 2 0 1 1 1 0 1 1 0 3 0 1 0 1 2 0 1 1 0 2 4 1 1 0 1 3 0 3 1 0 2 2 0 0 4 1 0 2 3 1 1 0 1 3 2 2 0 3 2 1 5 2 1 1 4 0 2 5 2 1 0 1 1 1 1 0 0 3 2 1 0 2 1 0
100
18 11 10 51 33 6 60 64 62 38 77 46 56 24 78 45 54 64 26 44 30 2 24 25 33 72 63 73 64 40 36 15 66 7 41 20 31 74 6 76 18 49 14 12 36 69...

output:

20

result:

ok single line: '20'

Test #104:

score: 25
Accepted
time: 0ms
memory: 18160kb

input:

60
0 0 3 7 7 1 0 1 7 0 0 0 1 2 1 2 4 0 1 1 2 0 2 4 2 3 0 0 3 0 6 1 0 0 1 1 4 6 1 0 2 2 0 3 1 1 1 0 0 0 3 1 0 0 1 0 0 1 1 1
100
13 36 4 8 37 58 2 17 31 36 43 12 41 38 55 37 2 32 50 25 2 23 6 43 16 4 29 4 36 30 39 30 41 23 28 46 37 7 2 25 38 12 43 18 8 9 30 32 51 50 31 56 23 56 34 17 21 24 5 50 4 54 4...

output:

26

result:

ok single line: '26'

Test #105:

score: 25
Accepted
time: 0ms
memory: 18208kb

input:

50
1 0 2 3 2 2 0 3 5 2 3 0 2 4 2 2 1 3 0 0 2 3 0 1 4 0 2 2 1 0 1 2 7 8 4 4 4 1 0 3 2 3 0 0 3 3 0 3 3 2
100
4 30 33 19 6 37 39 43 21 38 36 8 3 45 5 13 10 26 35 17 34 48 25 32 46 40 9 14 1 3 37 27 34 35 14 33 34 8 10 47 47 40 49 4 14 35 44 7 25 25 19 42 12 44 37 11 18 9 18 7 12 47 34 25 15 9 28 43 40 ...

output:

20

result:

ok single line: '20'

Test #106:

score: 25
Accepted
time: 2ms
memory: 18348kb

input:

40
2 3 3 1 1 1 3 4 7 6 5 7 12 3 5 0 4 4 0 2 0 3 5 0 3 1 5 3 2 5 3 3 3 0 1 4 1 0 6 5
100
22 26 19 3 7 12 35 1 13 24 14 17 13 17 35 32 12 28 21 27 36 14 1 8 39 13 30 35 18 12 26 4 10 8 39 17 18 13 5 25 30 29 14 28 39 34 7 3 12 17 10 8 16 11 12 29 10 33 9 10 19 39 22 31 6 38 23 10 3 39 20 18 23 9 31 26...

output:

10

result:

ok single line: '10'

Test #107:

score: 25
Accepted
time: 2ms
memory: 18192kb

input:

30
1 1 5 2 2 2 0 0 3 1 0 0 1 5 1 7 3 5 5 6 0 8 3 8 1 2 2 0 2 0
100
29 11 15 15 22 12 19 24 23 23 14 21 25 13 20 21 5 1 15 11 15 3 17 13 16 14 21 8 24 20 24 18 10 26 6 14 5 5 16 25 16 19 19 5 23 26 28 7 18 20 10 12 20 23 6 22 3 22 17 29 26 14 3 9 22 3 5 19 22 3 10 13 9 10 4 11 19 2 3 15 17 13 18 20 2...

output:

33

result:

ok single line: '33'

Test #108:

score: 25
Accepted
time: 1ms
memory: 16220kb

input:

22
1 2 0 0 12 13 0 7 0 0 7 0 3 7 6 6 9 8 10 7 11 1
100
15 9 18 10 3 20 4 3 17 16 10 14 6 21 5 9 6 7 14 11 7 3 21 2 1 5 8 18 4 6 9 2 1 4 15 14 5 12 10 19 16 19 8 20 13 5 20 20 10 13 14 21 8 1 11 16 7 16 12 8 20 17 10 5 6 18 15 16 15 3 5 20 18 4 19 12 16 14 12 16 21 18 18 3 5 19 10 11 11 2 6 5 6 7 15 ...

output:

23

result:

ok single line: '23'

Test #109:

score: 25
Accepted
time: 1ms
memory: 16048kb

input:

16
1 12 5 10 7 18 10 3 0 1 4 0 11 17 13 2
100
9 1 11 10 13 8 14 5 2 12 6 4 10 12 10 9 15 2 7 13 2 6 13 11 10 10 14 6 3 1 4 6 10 6 14 15 5 1 1 2 2 5 7 12 14 13 14 4 5 11 6 4 7 3 12 14 9 14 2 11 6 7 4 4 5 15 14 9 8 14 9 13 12 6 3 10 3 6 6 2 14 2 7 10 6 7 1 12 1 6 6 15 13 7 4 11 13 11 5 1

output:

20

result:

ok single line: '20'

Test #110:

score: 25
Accepted
time: 0ms
memory: 14172kb

input:

11
6 2 13 4 4 19 18 12 0 18 4
100
3 5 1 10 4 6 10 3 9 7 8 2 9 1 8 3 9 4 7 5 5 10 6 2 10 8 8 8 6 7 10 10 8 7 7 10 10 5 9 4 7 4 10 1 8 6 6 9 1 2 1 1 10 10 3 1 9 7 7 5 9 9 7 10 4 6 5 10 5 10 8 8 6 1 2 5 6 9 7 3 5 3 8 6 2 3 6 8 3 2 6 1 4 2 10 1 3 3 9 4

output:

17

result:

ok single line: '17'

Test #111:

score: 25
Accepted
time: 1ms
memory: 14104kb

input:

7
11 7 11 29 31 35 18
100
2 4 3 1 2 6 6 6 1 5 3 1 2 3 1 4 1 3 5 1 1 1 2 3 6 1 5 4 6 6 2 1 6 4 3 1 2 5 4 3 1 5 4 5 6 2 2 3 3 3 5 6 5 4 5 6 6 6 4 1 5 5 2 2 2 3 4 4 5 6 1 5 6 5 6 3 2 4 5 4 5 1 1 4 2 2 5 2 1 6 3 6 4 3 5 4 2 6 5 3

output:

13

result:

ok single line: '13'

Test #112:

score: 25
Accepted
time: 0ms
memory: 14084kb

input:

5
7 34 18 39 20
100
3 2 4 1 1 3 2 1 2 4 2 4 2 4 1 3 1 2 3 2 1 4 3 2 1 1 3 2 4 2 3 2 3 4 2 1 3 3 1 3 4 3 3 1 3 3 2 4 4 1 2 1 2 2 4 1 2 2 4 4 2 4 4 4 3 3 3 3 3 3 1 3 1 4 1 2 2 1 1 4 4 2 3 1 4 2 2 3 2 3 1 4 4 1 1 2 2 1 2 3

output:

11

result:

ok single line: '11'

Test #113:

score: 25
Accepted
time: 1ms
memory: 14008kb

input:

4
16 52 22 5
100
2 2 2 3 2 3 1 3 3 2 3 3 2 2 3 3 3 2 3 1 3 1 1 1 2 3 1 1 3 2 1 2 3 2 2 2 1 2 1 3 1 3 3 2 2 2 1 1 3 3 2 3 2 1 3 3 3 3 2 1 3 3 1 2 3 1 2 3 1 1 3 1 1 2 1 1 2 3 1 2 3 2 1 3 3 3 2 1 1 1 3 2 2 3 2 2 3 2 1 1

output:

23

result:

ok single line: '23'

Test #114:

score: 25
Accepted
time: 1ms
memory: 12104kb

input:

3
32 5 34
100
2 2 2 2 2 2 1 2 1 1 2 1 1 1 1 2 1 1 2 1 1 1 2 1 1 2 2 2 2 2 1 1 2 2 2 2 1 2 2 2 1 2 1 2 1 1 1 2 1 1 1 2 2 2 1 1 2 2 2 2 2 1 2 2 2 2 1 1 2 2 1 1 2 2 2 1 1 2 1 1 1 2 2 2 1 1 2 2 2 2 2 1 2 1 1 1 1 2 2 2

output:

29

result:

ok single line: '29'

Test #115:

score: 25
Accepted
time: 0ms
memory: 14000kb

input:

7
0 1 49 0 49 1 0
100
2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 3 4

output:

2

result:

ok single line: '2'

Test #116:

score: 25
Accepted
time: 1ms
memory: 14016kb

input:

7
0 49 1 0 1 49 0
100
2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 1 6

output:

2

result:

ok single line: '2'

Test #117:

score: 25
Accepted
time: 1ms
memory: 15988kb

input:

4
1 2 97 1
100
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 3 2

output:

1

result:

ok single line: '1'

Test #118:

score: 25
Accepted
time: 1ms
memory: 14060kb

input:

4
1 79 20 1
100
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 3 2

output:

1

result:

ok single line: '1'

Test #119:

score: 25
Accepted
time: 2ms
memory: 13976kb

input:

3
40 40 40
100
1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2

output:

10

result:

ok single line: '10'

Test #120:

score: 25
Accepted
time: 0ms
memory: 15988kb

input:

4
30 30 30 30
100
1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1

output:

13

result:

ok single line: '13'

Test #121:

score: 25
Accepted
time: 0ms
memory: 15916kb

input:

4
0 50 50 0
100
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2

output:

0

result:

ok single line: '0'

Test #122:

score: 25
Accepted
time: 0ms
memory: 16404kb

input:

72
0 0 0 0 0 1 0 1 0 0 1 1 0 2 0 0 2 1 1 0 0 1 0 1 1 1 0 1 1 1 1 2 0 1 2 1 0 0 0 0 0 1 0 1 0 0 1 1 0 2 0 0 2 1 1 0 0 1 0 1 1 1 0 1 1 1 1 2 0 1 2 1
48
1 2 4 5 7 8 10 11 13 14 16 17 19 20 22 23 25 26 28 29 31 32 34 35 38 37 41 40 44 43 47 46 50 49 53 52 56 55 59 58 62 61 65 64 68 67 71 70

output:

12

result:

ok single line: '12'

Subtask #6:

score: 10
Accepted

Dependency #5:

100%
Accepted

Test #123:

score: 10
Accepted
time: 3ms
memory: 65388kb

input:

600
0 0 0 2 2 2 0 0 0 1 0 0 0 1 1 1 0 2 0 1 0 0 1 0 0 1 1 1 0 0 2 1 0 1 1 2 1 0 0 1 1 2 0 1 1 0 0 1 0 0 0 1 0 0 0 0 1 0 0 0 1 0 2 1 0 1 0 2 2 0 0 0 0 0 0 0 1 2 0 0 0 0 0 0 1 0 0 1 0 0 0 3 2 1 1 0 0 0 0 0 0 0 0 1 0 0 1 1 3 1 0 2 0 0 0 1 0 2 0 0 0 0 0 0 1 1 0 1 0 2 1 1 1 0 0 0 0 0 1 1 0 0 0 1 0 0 0 1 ...

output:

80

result:

ok single line: '80'

Test #124:

score: 10
Accepted
time: 4ms
memory: 77656kb

input:

600
0 2 1 1 2 0 0 0 2 3 2 2 1 1 2 1 0 0 1 0 0 0 0 2 0 0 0 0 0 1 1 0 2 2 1 3 1 0 1 3 1 0 0 1 1 2 0 1 0 1 2 0 0 1 0 3 1 3 4 0 1 1 2 1 0 1 3 1 2 1 3 1 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 3 1 0 0 1 1 1 0 0 0 2 2 0 0 0 1 2 0 1 1 0 2 1 3 0 0 1 0 0 0 1 2 0 0 0 0 0 0 2 0 0 0 0 2 1 0 0 0 1 2 1 0 0 4 3 0 0 2 1 1 1 ...

output:

103

result:

ok single line: '103'

Test #125:

score: 10
Accepted
time: 3ms
memory: 81940kb

input:

600
1 4 2 0 1 1 0 1 1 1 1 0 0 2 1 1 1 1 1 3 2 1 1 0 2 2 2 0 1 1 2 1 1 1 2 3 1 0 1 1 0 0 1 2 0 0 1 0 0 1 3 1 1 0 0 0 1 1 1 3 1 0 0 0 3 1 0 0 0 2 2 0 0 0 1 3 0 2 1 4 2 1 0 2 1 0 1 0 0 0 1 3 1 1 2 0 2 2 1 2 0 0 0 0 1 2 1 0 1 0 0 1 0 1 0 0 3 0 0 1 0 2 0 2 0 1 3 1 2 3 2 1 1 0 3 1 2 1 0 2 0 2 0 0 1 2 1 0 ...

output:

148

result:

ok single line: '148'

Test #126:

score: 10
Accepted
time: 3ms
memory: 83832kb

input:

600
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

180

result:

ok single line: '180'

Test #127:

score: 10
Accepted
time: 4ms
memory: 83608kb

input:

600
8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8...

output:

0

result:

ok single line: '0'

Test #128:

score: 10
Accepted
time: 8ms
memory: 77560kb

input:

500
0 1 3 2 0 2 3 0 2 1 1 2 2 0 0 1 3 1 1 0 1 0 2 0 0 0 0 0 2 0 2 0 0 0 1 1 1 0 0 1 1 1 2 2 3 0 0 2 3 0 1 1 0 2 3 2 1 2 1 0 0 3 1 1 2 0 0 1 2 2 0 3 2 0 0 2 4 2 2 3 1 2 1 0 1 1 1 1 0 2 1 1 0 0 3 3 4 2 2 3 1 2 1 0 0 0 1 1 0 2 0 1 0 1 1 2 3 0 1 1 2 0 3 0 0 1 1 1 1 2 1 0 1 1 0 0 1 2 2 0 1 0 2 4 6 5 3 6 ...

output:

124

result:

ok single line: '124'

Test #129:

score: 10
Accepted
time: 3ms
memory: 69788kb

input:

400
1 2 1 6 1 1 2 4 2 1 1 0 2 1 1 3 2 0 3 0 0 1 1 0 2 1 0 0 1 2 1 0 1 0 0 1 1 0 1 0 0 1 1 0 1 3 3 1 0 3 1 1 3 6 2 2 2 1 1 2 0 0 1 2 0 3 0 1 0 0 3 2 2 2 0 3 0 0 2 3 0 3 3 1 1 1 1 0 0 0 1 2 1 1 3 4 3 3 5 0 1 0 1 0 0 0 2 0 2 1 3 2 1 1 0 1 0 0 0 3 5 0 0 2 2 1 1 0 1 2 5 4 0 2 1 2 5 3 1 0 0 0 1 1 1 0 4 3 ...

output:

166

result:

ok single line: '166'

Test #130:

score: 10
Accepted
time: 4ms
memory: 65232kb

input:

300
0 0 1 2 2 2 2 7 4 3 2 2 1 4 0 1 1 2 4 0 2 0 1 0 2 1 2 0 0 3 4 4 0 1 1 1 1 5 3 2 1 2 3 0 0 6 2 2 1 1 6 1 4 4 1 1 1 0 0 1 0 0 5 3 2 1 3 3 1 4 4 1 4 4 1 0 3 0 1 3 3 0 1 4 7 5 0 2 3 1 0 0 0 0 2 2 2 3 0 3 2 2 1 1 0 0 1 2 1 1 1 0 3 0 2 0 0 6 0 7 2 4 1 1 0 3 2 0 2 0 0 0 2 2 1 0 3 1 1 1 0 3 3 1 0 1 4 0 ...

output:

149

result:

ok single line: '149'

Test #131:

score: 10
Accepted
time: 4ms
memory: 58956kb

input:

200
5 1 0 3 0 6 5 0 2 8 4 2 5 0 5 3 4 6 3 4 1 3 4 0 4 3 2 6 4 4 3 9 4 2 3 1 1 7 1 7 0 1 0 0 1 3 4 1 4 2 2 1 0 3 0 2 1 0 1 4 2 0 5 8 3 3 5 2 0 0 8 7 6 5 1 1 4 6 5 3 4 4 1 1 1 6 2 6 2 5 0 3 0 2 3 3 0 3 0 3 0 1 2 2 2 0 2 0 2 0 5 7 4 5 4 3 1 0 0 2 1 5 8 5 3 1 5 7 4 2 2 6 2 8 1 5 5 3 10 2 4 6 2 0 6 5 3 2...

output:

132

result:

ok single line: '132'

Test #132:

score: 10
Accepted
time: 4ms
memory: 55080kb

input:

150
2 6 4 0 4 3 5 2 0 4 3 7 1 11 1 2 5 1 3 6 1 0 1 2 2 4 4 0 9 7 5 0 9 0 0 1 1 4 2 1 1 2 4 2 0 5 1 7 14 13 3 7 0 0 1 3 1 5 4 4 3 2 0 5 3 5 6 7 7 10 1 0 9 5 6 9 6 1 2 3 1 3 5 5 5 1 0 3 3 2 12 4 2 0 7 5 6 1 7 6 5 13 9 0 5 1 6 3 1 4 0 8 0 5 12 10 1 5 3 3 4 2 5 0 2 0 0 1 0 1 9 1 7 2 6 0 12 3 1 6 2 8 5 1...

output:

135

result:

ok single line: '135'

Test #133:

score: 10
Accepted
time: 4ms
memory: 53108kb

input:

100
2 7 0 3 5 9 5 8 10 8 10 0 1 6 4 5 0 6 11 4 11 3 8 4 2 9 4 3 1 4 9 0 10 1 9 6 9 8 9 12 8 10 9 4 13 9 9 3 8 10 9 10 1 3 2 1 4 10 3 10 8 10 8 2 1 1 14 2 7 2 3 10 3 0 0 3 18 1 5 5 7 8 15 6 0 8 14 12 7 5 2 3 3 8 3 5 7 15 5 1
600
35 77 91 14 83 44 34 63 82 63 72 11 14 81 78 86 78 32 62 28 59 96 19 24 ...

output:

132

result:

ok single line: '132'

Test #134:

score: 10
Accepted
time: 7ms
memory: 51100kb

input:

70
3 1 7 21 14 6 9 10 4 4 16 15 14 14 7 13 11 8 11 0 3 7 11 3 11 11 2 7 3 1 11 14 2 6 22 10 1 22 19 12 15 0 0 12 13 3 14 18 4 3 2 5 8 5 2 13 9 6 18 16 15 5 4 17 9 17 2 9 2 3
600
35 69 56 58 3 66 25 28 51 15 38 51 28 54 34 9 54 43 67 48 7 32 69 44 28 2 37 50 44 11 11 51 34 1 37 13 7 40 48 60 47 18 6 ...

output:

140

result:

ok single line: '140'

Test #135:

score: 10
Accepted
time: 3ms
memory: 51124kb

input:

50
7 3 18 23 18 22 8 5 19 19 4 10 5 20 10 19 6 2 9 15 12 17 0 3 2 1 4 11 8 8 7 9 7 8 7 6 4 21 25 0 25 9 22 7 15 15 16 1 21 6
600
35 34 48 9 39 27 4 47 45 15 4 43 20 41 11 33 12 48 33 12 28 47 35 44 48 11 32 18 11 1 19 25 37 44 19 6 16 11 20 13 43 6 43 26 27 19 5 9 13 48 33 30 12 6 33 44 21 41 42 22 ...

output:

156

result:

ok single line: '156'

Test #136:

score: 10
Accepted
time: 5ms
memory: 48720kb

input:

30
13 39 22 6 13 33 8 35 32 1 7 39 35 25 17 39 27 39 5 2 0 7 8 16 41 42 33 26 28 15
600
12 20 5 8 16 6 28 10 15 10 15 26 28 9 20 8 24 1 8 27 24 14 26 28 25 22 7 8 15 26 5 28 25 20 18 2 12 22 3 12 27 15 14 13 3 2 24 25 24 6 27 11 3 2 18 22 9 10 5 9 18 25 5 26 10 8 14 27 21 13 20 4 20 17 7 11 9 15 12 ...

output:

122

result:

ok single line: '122'

Test #137:

score: 10
Accepted
time: 0ms
memory: 44880kb

input:

20
17 4 17 20 22 56 38 7 38 57 2 4 37 52 31 27 45 1 11 13
600
15 6 3 4 4 19 5 8 19 16 3 10 9 2 17 4 13 14 17 6 17 3 16 17 14 12 13 10 10 4 2 17 10 4 19 17 13 7 15 5 5 13 11 4 9 4 1 6 19 19 7 16 4 10 3 2 11 6 3 2 15 10 10 9 4 19 16 14 4 7 12 7 14 7 9 19 10 17 7 11 11 14 11 12 13 8 1 8 15 14 17 17 8 4...

output:

175

result:

ok single line: '175'

Test #138:

score: 10
Accepted
time: 3ms
memory: 47040kb

input:

13
50 76 66 92 3 20 87 11 23 4 97 0 2
600
1 12 1 4 6 2 6 5 1 6 7 12 4 4 8 11 3 1 1 10 3 9 11 3 12 8 10 3 6 5 1 10 9 11 3 12 12 5 6 5 4 7 1 10 2 9 3 8 10 10 4 1 12 11 12 12 9 11 4 10 3 4 3 5 9 1 11 8 3 3 1 9 11 6 2 7 5 1 1 7 3 7 10 7 11 1 4 4 5 7 7 10 6 4 1 12 10 11 11 6 11 5 3 9 6 6 12 2 8 5 7 9 9 1...

output:

168

result:

ok single line: '168'

Test #139:

score: 10
Accepted
time: 5ms
memory: 44944kb

input:

8
39 76 63 176 174 23 29 33
600
4 3 1 5 6 7 4 6 4 6 3 1 3 4 7 7 3 2 2 5 4 4 1 4 3 7 3 7 1 7 6 3 4 3 6 2 7 2 4 4 3 5 5 6 6 6 2 7 7 6 6 5 1 6 7 6 1 3 4 6 3 3 5 2 4 6 7 1 6 2 2 4 1 3 2 6 6 1 7 4 4 7 2 5 1 4 7 7 1 3 4 7 7 3 4 3 6 4 1 7 4 5 2 4 3 3 1 7 3 3 5 2 3 3 5 2 4 1 3 5 2 6 6 7 7 6 7 1 5 6 2 4 2 3 ...

output:

151

result:

ok single line: '151'

Test #140:

score: 10
Accepted
time: 8ms
memory: 46960kb

input:

5
84 245 167 68 59
600
1 4 4 1 1 4 3 4 2 4 3 3 3 4 1 3 4 4 1 2 1 2 1 4 1 3 4 4 3 4 2 3 4 4 3 4 2 2 1 3 4 3 2 4 3 1 3 2 4 3 2 1 1 3 4 1 2 2 3 2 3 3 3 1 4 4 4 2 3 2 1 4 3 4 1 2 2 3 4 4 1 3 1 4 4 4 4 4 4 1 4 3 2 1 1 1 2 1 2 4 3 2 1 3 2 3 1 2 1 4 2 1 2 2 2 3 1 4 4 4 3 2 3 1 2 4 1 1 3 1 3 4 1 1 4 1 3 4 1...

output:

129

result:

ok single line: '129'

Test #141:

score: 10
Accepted
time: 4ms
memory: 48788kb

input:

4
127 317 240 71
600
1 3 3 1 3 1 3 1 2 2 2 1 2 3 3 3 3 2 3 1 1 2 3 3 2 1 2 1 2 1 2 2 3 3 3 1 1 1 3 3 1 3 2 3 1 3 3 3 1 2 3 3 2 3 2 1 2 1 3 2 3 2 2 3 2 2 1 2 3 2 1 3 1 1 1 1 3 1 3 2 2 2 1 2 2 1 3 3 1 3 1 3 2 1 3 3 2 1 1 2 3 3 3 2 2 2 1 1 3 1 1 1 1 3 1 3 1 1 3 1 3 2 3 2 1 1 3 3 2 1 3 3 3 1 2 2 3 3 1 3...

output:

41

result:

ok single line: '41'

Test #142:

score: 10
Accepted
time: 4ms
memory: 44964kb

input:

3
232 302 278
600
2 1 2 1 1 2 2 2 1 1 2 2 1 2 2 2 2 1 2 2 1 2 1 1 1 1 1 2 1 1 1 1 2 1 2 2 1 2 2 2 2 1 1 1 1 1 1 2 2 1 2 2 1 2 1 1 2 1 2 1 1 2 1 2 1 1 2 2 2 1 2 1 1 1 2 2 1 1 2 1 2 2 2 2 1 1 2 2 1 1 1 2 1 1 1 1 1 2 1 2 1 2 1 2 1 2 1 1 2 2 2 2 1 1 1 2 1 1 2 1 1 2 2 1 2 2 1 2 1 1 1 2 1 1 2 1 1 2 1 2 2 ...

output:

25

result:

ok single line: '25'

Test #143:

score: 10
Accepted
time: 4ms
memory: 61328kb

input:

333
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

166

result:

ok single line: '166'

Test #144:

score: 10
Accepted
time: 4ms
memory: 69400kb

input:

498
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

166

result:

ok single line: '166'

Test #145:

score: 10
Accepted
time: 0ms
memory: 44940kb

input:

7
0 1 299 0 299 1 0
600
2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 ...

output:

2

result:

ok single line: '2'

Test #146:

score: 10
Accepted
time: 3ms
memory: 44960kb

input:

7
0 299 1 0 1 299 0
600
2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 ...

output:

2

result:

ok single line: '2'

Test #147:

score: 10
Accepted
time: 4ms
memory: 44676kb

input:

4
1 597 2 1
600
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ...

output:

1

result:

ok single line: '1'

Test #148:

score: 10
Accepted
time: 4ms
memory: 45012kb

input:

4
1 138 461 1
600
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ...

output:

1

result:

ok single line: '1'

Test #149:

score: 10
Accepted
time: 4ms
memory: 71412kb

input:

499
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

166

result:

ok single line: '166'

Test #150:

score: 10
Accepted
time: 3ms
memory: 44868kb

input:

3
233 233 233
599
1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 ...

output:

67

result:

ok single line: '67'

Test #151:

score: 10
Accepted
time: 3ms
memory: 46992kb

input:

4
168 168 168 168
597
1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 ...

output:

87

result:

ok single line: '87'

Test #152:

score: 10
Accepted
time: 0ms
memory: 46896kb

input:

27
25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25
600
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 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 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 1 2 3...

output:

59

result:

ok single line: '59'

Test #153:

score: 10
Accepted
time: 3ms
memory: 65376kb

input:

302
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

299

result:

ok single line: '299'

Test #154:

score: 10
Accepted
time: 9ms
memory: 65372kb

input:

302
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

300

result:

ok single line: '300'

Test #155:

score: 10
Accepted
time: 3ms
memory: 65460kb

input:

302
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

299

result:

ok single line: '299'

Test #156:

score: 10
Accepted
time: 4ms
memory: 65456kb

input:

302
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

300

result:

ok single line: '300'

Test #157:

score: 10
Accepted
time: 3ms
memory: 65344kb

input:

302
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

299

result:

ok single line: '299'

Test #158:

score: 10
Accepted
time: 4ms
memory: 44988kb

input:

4
0 300 300 0
600
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 ...

output:

0

result:

ok single line: '0'

Test #159:

score: 10
Accepted
time: 4ms
memory: 61300kb

input:

432
0 0 0 0 0 1 0 1 0 0 1 1 0 2 0 0 2 1 0 3 0 0 3 1 1 0 0 1 0 1 1 1 0 1 1 1 1 2 0 1 2 1 1 3 0 1 3 1 2 0 0 2 0 1 2 1 0 2 1 1 2 2 0 2 2 1 2 3 0 2 3 1 0 0 0 0 0 1 0 1 0 0 1 1 0 2 0 0 2 1 0 3 0 0 3 1 1 0 0 1 0 1 1 1 0 1 1 1 1 2 0 1 2 1 1 3 0 1 3 1 2 0 0 2 0 1 2 1 0 2 1 1 2 2 0 2 2 1 2 3 0 2 3 1 0 0 0 0 ...

output:

102

result:

ok single line: '102'

Test #160:

score: 10
Accepted
time: 4ms
memory: 69704kb

input:

576
0 0 0 0 0 0 0 1 0 0 1 0 0 0 1 1 0 0 2 0 0 0 2 1 0 1 0 0 0 1 0 1 0 1 1 0 0 1 1 1 0 1 2 0 0 1 2 1 0 2 0 0 0 2 0 1 0 2 1 0 0 2 1 1 0 2 2 0 0 2 2 1 1 0 0 0 1 0 0 1 1 0 1 0 1 0 1 1 1 0 2 0 1 0 2 1 1 1 0 0 1 1 0 1 1 1 1 0 1 1 1 1 1 1 2 0 1 1 2 1 1 2 0 0 1 2 0 1 1 2 1 0 1 2 1 1 1 2 2 0 1 2 2 1 0 0 0 0 ...

output:

107

result:

ok single line: '107'

Test #161:

score: 10
Accepted
time: 4ms
memory: 42896kb

input:

186
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

190

result:

ok single line: '190'

Test #162:

score: 10
Accepted
time: 3ms
memory: 52876kb

input:

308
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

124

result:

ok single line: '124'

Test #163:

score: 10
Accepted
time: 4ms
memory: 44888kb

input:

300
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

68

result:

ok single line: '68'

Test #164:

score: 10
Accepted
time: 6ms
memory: 67532kb

input:

512
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

69

result:

ok single line: '69'

Subtask #7:

score: 15
Accepted

Dependency #6:

100%
Accepted

Test #165:

score: 15
Accepted
time: 72ms
memory: 346396kb

input:

3500
0 0 0 1 0 0 0 0 0 0 1 0 0 0 1 1 0 0 0 0 2 1 2 0 0 0 0 0 0 2 3 0 0 0 0 0 1 2 1 0 1 2 2 0 0 0 0 1 0 1 0 0 1 1 1 1 1 1 0 1 1 1 0 0 0 0 1 2 1 1 1 0 0 0 0 0 1 2 1 3 1 0 0 0 0 0 0 0 0 1 2 1 1 0 0 0 0 0 0 0 1 1 0 0 1 0 0 0 1 1 0 0 2 0 2 2 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1 0 1 0 0 0 1 0 0 0 0 0 0 0 0...

output:

442

result:

ok single line: '442'

Test #166:

score: 15
Accepted
time: 129ms
memory: 403828kb

input:

3500
0 0 0 2 1 0 1 0 0 0 0 1 1 0 0 3 0 0 0 0 0 1 3 3 0 0 0 0 2 0 0 0 0 2 3 1 2 2 1 3 1 0 0 2 2 1 1 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 1 0 1 1 0 0 0 1 0 0 1 0 2 0 1 2 0 0 2 0 2 3 3 0 1 3 1 1 0 2 0 1 1 1 2 2 1 0 0 1 0 2 3 2 1 1 0 0 1 3 1 0 1 0 2 1 2 0 1 0 1 0 4 2 1 1 1 0 1 0 0 1 0 2 0 1 2 0 1 3 1 4...

output:

673

result:

ok single line: '673'

Test #167:

score: 15
Accepted
time: 180ms
memory: 446836kb

input:

3500
1 0 0 2 1 0 0 1 0 0 0 0 2 1 1 0 1 2 0 3 4 1 0 1 0 2 3 2 0 1 2 2 2 2 0 1 0 0 4 1 3 0 1 0 0 0 0 0 0 2 3 1 1 2 0 0 1 1 0 0 0 2 0 1 0 0 0 2 1 2 1 0 0 0 0 0 1 1 0 1 2 1 2 1 0 1 1 2 1 4 2 0 1 2 0 1 1 0 0 1 3 0 0 1 1 0 0 1 1 2 3 0 0 3 0 4 1 0 0 1 2 3 2 1 1 3 1 3 2 0 1 0 2 1 1 2 2 3 1 1 1 0 0 0 1 0 1 1...

output:

799

result:

ok single line: '799'

Test #168:

score: 15
Accepted
time: 170ms
memory: 447060kb

input:

3500
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

1083

result:

ok single line: '1083'

Test #169:

score: 15
Accepted
time: 123ms
memory: 446524kb

input:

3500
8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 ...

output:

0

result:

ok single line: '0'

Test #170:

score: 15
Accepted
time: 167ms
memory: 401988kb

input:

2800
0 0 0 0 0 1 0 3 1 1 0 2 2 2 2 3 0 1 1 4 2 2 0 0 0 1 1 3 0 1 2 2 2 1 0 1 1 0 0 3 6 5 8 3 3 0 0 1 0 0 0 3 0 1 0 3 1 2 1 3 3 0 1 0 0 2 2 1 0 0 2 3 1 0 2 1 0 0 0 1 1 0 0 1 1 3 1 5 3 1 3 0 5 0 0 2 2 2 5 0 1 0 0 1 2 1 1 0 0 1 4 0 1 1 1 1 2 3 0 0 0 1 2 1 1 1 1 2 0 2 3 3 1 1 1 5 2 1 0 0 0 2 1 1 3 1 0 2...

output:

811

result:

ok single line: '811'

Test #171:

score: 15
Accepted
time: 150ms
memory: 359016kb

input:

2100
2 0 1 1 0 3 1 2 3 1 5 5 5 5 4 1 1 2 2 3 5 2 2 4 0 0 2 5 2 1 1 2 3 0 2 0 0 6 5 0 2 1 1 1 1 0 0 0 1 3 4 1 0 3 3 0 3 1 1 1 1 1 0 2 6 3 0 1 1 0 0 1 0 3 0 2 2 0 1 4 4 2 2 1 1 0 0 0 3 0 2 4 3 1 1 1 3 5 0 3 3 2 0 3 1 6 4 1 6 7 1 6 8 0 0 1 1 4 4 8 1 2 5 2 2 0 2 1 0 2 4 0 0 3 3 2 1 1 2 2 0 0 0 2 1 3 4 2...

output:

815

result:

ok single line: '815'

Test #172:

score: 15
Accepted
time: 139ms
memory: 321484kb

input:

1500
0 2 2 1 1 5 3 3 0 1 4 2 3 8 3 0 1 0 2 3 2 0 3 2 0 3 2 0 0 6 0 0 2 0 2 4 1 0 0 1 4 0 1 0 1 3 0 4 1 1 7 1 0 4 4 1 7 3 4 2 3 1 1 3 4 2 1 4 2 1 0 1 5 1 0 2 0 4 5 1 3 0 0 4 2 0 4 3 2 3 4 0 3 0 3 2 2 0 1 2 4 2 7 0 4 3 0 0 5 1 2 5 1 4 0 11 5 0 2 3 2 0 1 4 5 0 3 6 3 2 1 1 1 2 2 3 2 0 3 0 3 5 2 1 1 6 7 ...

output:

816

result:

ok single line: '816'

Test #173:

score: 15
Accepted
time: 131ms
memory: 294728kb

input:

1100
5 4 7 3 3 3 0 0 4 3 5 0 2 3 6 3 1 0 3 5 2 4 5 2 2 1 3 6 1 0 0 9 7 6 0 0 2 2 0 4 4 7 5 5 0 2 6 4 3 3 4 2 0 5 2 6 4 1 0 3 2 0 0 0 3 1 0 3 2 1 0 0 2 4 7 2 1 1 4 5 0 2 0 2 3 4 5 1 1 0 3 1 2 7 1 10 4 6 2 2 4 1 2 1 0 6 3 1 3 5 3 3 3 1 2 1 4 4 3 3 6 3 1 4 5 3 2 5 7 3 3 7 8 8 0 7 9 5 2 4 2 4 1 2 1 5 4 ...

output:

821

result:

ok single line: '821'

Test #174:

score: 15
Accepted
time: 118ms
memory: 268948kb

input:

700
4 9 4 0 0 2 5 5 12 4 4 4 1 15 9 4 0 4 9 3 1 12 10 9 6 1 1 3 2 7 3 10 6 8 10 6 3 5 4 7 0 5 5 20 14 0 3 0 2 7 3 0 16 13 11 3 0 4 8 2 7 3 3 11 4 1 14 8 3 9 5 2 0 0 4 7 2 6 8 0 1 2 4 8 6 5 4 4 1 5 7 9 6 7 2 5 1 9 13 9 6 5 3 2 4 8 9 7 3 9 3 8 5 8 5 1 8 12 8 1 0 0 2 8 3 3 4 6 0 0 4 10 7 8 5 2 4 1 2 8 ...

output:

777

result:

ok single line: '777'

Test #175:

score: 15
Accepted
time: 113ms
memory: 252416kb

input:

400
8 15 7 5 11 6 5 12 24 0 17 8 5 11 15 17 12 1 5 19 11 9 16 16 16 13 9 0 4 11 15 20 7 19 9 14 16 8 13 7 1 7 6 6 3 4 5 1 1 14 6 10 0 2 4 1 4 8 0 7 5 4 12 4 14 9 2 1 9 11 2 15 8 7 7 17 19 14 13 13 16 12 14 3 2 5 6 2 1 17 7 12 10 4 15 11 14 15 12 9 13 6 6 3 15 14 7 2 2 14 23 18 0 9 13 10 4 14 0 1 0 1...

output:

742

result:

ok single line: '742'

Test #176:

score: 15
Accepted
time: 118ms
memory: 239388kb

input:

200
11 20 30 14 31 13 30 30 12 19 11 19 6 7 10 10 18 16 23 5 30 33 28 3 17 21 22 36 2 18 28 3 13 15 27 32 12 0 6 9 1 22 13 30 15 37 8 11 17 6 29 38 34 26 26 39 26 31 5 22 16 35 13 3 29 16 43 8 3 10 7 20 2 35 22 32 14 10 7 16 3 13 6 1 42 4 39 21 16 17 11 4 26 4 8 8 32 32 30 26 16 9 0 21 12 11 19 19 3...

output:

669

result:

ok single line: '669'

Test #177:

score: 15
Accepted
time: 110ms
memory: 233156kb

input:

100
26 53 61 13 82 38 13 43 84 16 12 54 67 33 12 51 69 11 42 20 36 42 31 78 74 26 3 35 16 41 15 4 16 37 57 59 33 60 24 18 6 73 63 17 58 25 62 38 65 45 19 41 21 2 6 64 33 26 38 1 6 45 23 13 57 43 50 34 41 10 42 32 64 20 7 43 13 3 13 30 41 12 3 13 3 25 73 59 66 38 36 22 8 22 63 2 6 71 40 22
3500
27 94...

output:

826

result:

ok single line: '826'

Test #178:

score: 15
Accepted
time: 102ms
memory: 229104kb

input:

50
31 21 136 79 152 11 82 143 148 134 86 88 51 92 24 128 15 61 129 70 36 90 121 38 141 109 122 127 72 83 106 74 15 110 102 120 71 123 123 25 123 35 80 20 57 89 2 118 67 6
3500
48 42 36 31 2 37 16 1 19 45 17 49 26 31 48 40 7 34 4 10 38 3 29 48 39 6 16 47 9 29 11 18 14 45 18 45 4 11 41 48 7 29 43 2 24...

output:

417

result:

ok single line: '417'

Test #179:

score: 15
Accepted
time: 118ms
memory: 227808kb

input:

30
65 152 13 213 209 101 5 108 231 21 96 125 128 147 107 110 177 211 93 239 114 219 97 95 131 79 90 220 194 5
3500
25 5 26 1 18 11 16 6 1 22 6 22 2 6 8 28 27 28 25 2 28 1 11 26 25 5 18 6 15 24 4 20 9 7 11 27 3 8 2 6 4 7 21 7 26 2 23 24 18 24 13 25 6 6 11 21 18 12 18 22 14 12 6 17 11 14 6 20 28 19 19...

output:

550

result:

ok single line: '550'

Test #180:

score: 15
Accepted
time: 128ms
memory: 227456kb

input:

15
149 258 351 384 246 343 467 26 142 374 435 168 346 246 215
3500
14 9 11 3 7 8 10 5 6 6 14 10 6 3 9 10 13 12 8 2 3 6 12 1 6 1 2 13 3 12 11 13 3 9 7 13 10 7 11 6 6 11 4 8 10 14 1 1 2 8 13 13 9 6 3 9 14 8 8 11 10 7 12 5 6 8 9 9 5 2 11 9 7 3 7 4 2 5 11 5 3 3 3 4 14 6 5 3 10 14 4 5 10 4 9 3 1 3 1 11 5...

output:

428

result:

ok single line: '428'

Test #181:

score: 15
Accepted
time: 175ms
memory: 227224kb

input:

8
503 253 928 167 610 575 814 127
3500
5 2 3 1 3 2 6 6 2 2 2 3 2 4 6 1 3 7 2 2 2 1 1 3 7 3 7 3 4 4 1 3 4 4 4 4 4 2 5 5 4 5 2 3 2 3 1 7 6 6 4 5 4 3 2 3 7 5 7 1 1 1 5 6 3 1 6 3 2 1 4 5 2 3 7 1 3 7 7 6 7 6 1 6 5 2 6 4 3 6 1 3 6 1 4 1 3 3 2 7 6 4 7 2 6 7 1 1 1 4 6 5 6 2 7 3 5 3 5 3 1 6 4 2 3 6 6 4 2 2 2...

output:

232

result:

ok single line: '232'

Test #182:

score: 15
Accepted
time: 629ms
memory: 229516kb

input:

6
378 1273 508 16 854 227
3500
3 4 5 5 2 3 5 2 5 1 1 5 2 1 3 4 5 5 5 4 4 3 5 2 4 1 1 5 3 5 4 4 5 4 4 1 3 4 5 2 1 3 4 4 2 1 5 2 5 1 4 4 4 4 4 3 4 3 1 3 3 2 1 1 3 5 5 5 3 4 5 1 1 4 3 3 4 3 2 4 4 3 1 4 3 1 1 4 5 5 3 5 4 2 4 4 2 3 2 2 1 5 3 5 1 3 4 4 1 3 1 3 3 5 4 2 5 4 1 1 3 4 3 2 1 2 5 3 2 1 3 4 3 5 2...

output:

719

result:

ok single line: '719'

Test #183:

score: 15
Accepted
time: 347ms
memory: 229860kb

input:

4
166 1325 1411 1074
3500
3 2 3 2 3 1 3 3 2 1 2 3 2 2 3 2 1 2 3 1 3 2 2 1 2 2 2 2 2 2 3 2 1 2 2 1 2 3 1 2 1 3 2 1 1 1 2 2 2 1 2 3 3 3 2 1 2 3 2 3 1 2 3 2 2 2 2 1 2 2 2 2 1 3 2 2 1 3 3 1 2 2 2 3 3 2 1 3 1 2 2 3 1 2 3 3 2 2 1 3 2 1 2 2 3 2 3 3 2 1 3 2 2 2 3 1 2 1 2 3 3 3 2 1 3 3 2 1 1 2 2 1 3 3 1 2 3 ...

output:

515

result:

ok single line: '515'

Test #184:

score: 15
Accepted
time: 138ms
memory: 226976kb

input:

3
764 2191 1684
3500
2 1 1 2 2 2 2 2 2 2 2 2 1 2 2 1 1 2 1 2 1 1 2 1 1 2 1 2 1 1 1 2 2 2 2 2 1 2 1 2 2 2 1 2 2 2 2 2 2 2 1 2 2 1 2 1 1 1 2 2 2 1 1 2 1 2 1 2 1 2 1 2 2 2 2 1 2 2 2 1 1 1 2 1 2 2 1 2 2 2 1 2 1 2 2 1 1 1 1 2 2 1 1 1 1 2 2 1 1 1 2 2 2 2 2 1 1 1 2 2 2 2 1 1 2 1 1 1 1 1 2 1 2 2 2 1 1 1 1 2...

output:

289

result:

ok single line: '289'

Test #185:

score: 15
Accepted
time: 169ms
memory: 371508kb

input:

2333
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

1166

result:

ok single line: '1166'

Test #186:

score: 15
Accepted
time: 177ms
memory: 445044kb

input:

3498
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

1166

result:

ok single line: '1166'

Test #187:

score: 15
Accepted
time: 120ms
memory: 227696kb

input:

7
0 1 1749 0 1749 1 0
3500
2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2...

output:

2

result:

ok single line: '2'

Test #188:

score: 15
Accepted
time: 111ms
memory: 227528kb

input:

7
0 1749 1 0 1 1749 0
3500
2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2...

output:

2

result:

ok single line: '2'

Test #189:

score: 15
Accepted
time: 128ms
memory: 227596kb

input:

4
1 2 3497 1
3500
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ...

output:

1

result:

ok single line: '1'

Test #190:

score: 15
Accepted
time: 93ms
memory: 225912kb

input:

4
1 2736 763 1
3500
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ...

output:

1

result:

ok single line: '1'

Test #191:

score: 15
Accepted
time: 174ms
memory: 445008kb

input:

3499
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

1166

result:

ok single line: '1166'

Test #192:

score: 15
Accepted
time: 212ms
memory: 227360kb

input:

3
1400 1400 1400
3498
1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 ...

output:

349

result:

ok single line: '349'

Test #193:

score: 15
Accepted
time: 410ms
memory: 227124kb

input:

4
1000 1000 1000 1000
3500
1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2...

output:

500

result:

ok single line: '500'

Test #194:

score: 15
Accepted
time: 92ms
memory: 229488kb

input:

4
0 1750 1750 0
3500
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3...

output:

0

result:

ok single line: '0'

Test #195:

score: 15
Accepted
time: 68ms
memory: 266424kb

input:

1770
0 0 0 0 0 1 0 1 0 0 1 1 0 2 0 0 2 1 0 3 0 0 3 1 0 4 0 0 4 1 1 0 0 1 0 1 1 1 0 1 1 1 1 2 0 1 2 1 1 3 0 1 3 1 1 4 0 1 4 1 2 0 0 2 0 1 2 1 0 2 1 1 2 2 0 2 2 1 2 3 0 2 3 1 2 4 0 2 4 1 3 0 0 3 0 1 3 1 0 3 1 1 3 2 0 3 2 1 3 3 0 3 3 1 3 4 0 3 4 1 0 0 0 0 0 1 0 1 0 0 1 1 0 2 0 0 2 1 0 3 0 0 3 1 0 4 0 0...

output:

540

result:

ok single line: '540'

Test #196:

score: 15
Accepted
time: 51ms
memory: 182572kb

input:

762
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

1274

result:

ok single line: '1274'

Test #197:

score: 15
Accepted
time: 31ms
memory: 161556kb

input:

980
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

593

result:

ok single line: '593'

Test #198:

score: 15
Accepted
time: 49ms
memory: 210968kb

input:

1470
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

552

result:

ok single line: '552'

Test #199:

score: 15
Accepted
time: 106ms
memory: 344124kb

input:

2688
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

604

result:

ok single line: '604'

Test #200:

score: 15
Accepted
time: 83ms
memory: 311624kb

input:

2560
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

379

result:

ok single line: '379'

Subtask #8:

score: 0
Time Limit Exceeded

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Dependency #5:

100%
Accepted

Dependency #6:

100%
Accepted

Dependency #7:

100%
Accepted

Test #201:

score: 5
Accepted
time: 251ms
memory: 716908kb

input:

8000
0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 3 1 1 0 0 0 0 0 0 0 0 0 0 2 2 0 0 0 1 1 0 0 0 0 0 0 0 0 1 1 1 0 0 1 0 0 2 0 0 0 0 0 0 0 3 1 1 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 2 4 0 0 0 1 1 0 1 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 1 1 0 1 1 0 2 2 0 0 1 0 0 1 2 1 1 0 1 0 0 0 0 0 1 0 1 0 0 0 0 0 0 1 0 0...

output:

787

result:

ok single line: '787'

Test #202:

score: 5
Accepted
time: 584ms
memory: 881048kb

input:

8000
1 1 0 2 2 0 0 0 1 1 0 1 1 1 0 1 2 3 5 0 0 0 0 1 0 0 0 1 2 0 0 1 0 1 3 0 0 1 1 1 2 0 2 0 0 1 1 2 0 0 0 2 1 1 0 3 1 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 2 0 0 0 0 0 0 1 1 0 0 2 2 0 0 2 1 0 1 1 1 1 3 0 0 0 1 0 2 2 0 0 1 2 0 0 0 0 1 2 0 1 4 2 0 0 1 0 0 1 1 1 3 1 2 2 0 0 0 0 1 1 2 1 0 0 0 2 1 2 0 0 0 1 1 2...

output:

1385

result:

ok single line: '1385'

Test #203:

score: 5
Accepted
time: 941ms
memory: 1004072kb

input:

8000
1 1 1 2 3 2 0 2 2 2 2 0 0 0 1 3 0 0 0 1 0 1 1 1 0 3 5 0 0 1 1 0 1 1 0 0 2 0 0 3 3 1 0 1 3 3 0 0 0 2 2 0 0 0 1 0 1 3 0 1 0 1 2 4 4 0 0 0 1 0 0 2 3 0 0 3 5 2 1 1 2 0 1 0 0 0 0 0 0 2 2 0 3 1 0 2 5 0 0 0 0 0 1 0 1 1 1 0 1 2 1 0 0 1 0 0 0 1 0 2 1 0 2 1 0 1 0 0 1 0 0 0 1 1 0 0 0 0 1 2 0 3 0 0 0 1 1 0...

output:

1880

result:

ok single line: '1880'

Test #204:

score: 5
Accepted
time: 936ms
memory: 1004856kb

input:

8000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

2472

result:

ok single line: '2472'

Test #205:

score: 5
Accepted
time: 619ms
memory: 1005568kb

input:

8000
8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 8000 ...

output:

0

result:

ok single line: '0'

Test #206:

score: 5
Accepted
time: 837ms
memory: 881604kb

input:

6000
1 0 0 0 0 1 2 0 1 0 0 0 0 0 0 1 3 0 1 0 0 4 0 2 5 1 0 1 0 4 4 0 0 0 0 0 2 0 2 1 4 1 1 2 0 1 2 4 0 0 5 1 0 0 4 0 0 2 1 1 1 2 0 0 0 2 1 0 4 3 0 0 6 1 1 2 0 0 2 0 2 3 2 1 1 0 0 0 2 2 0 0 0 1 3 1 2 8 8 0 1 3 1 1 0 0 2 0 3 0 1 4 1 0 1 4 2 4 1 0 2 1 3 0 0 2 3 4 0 2 2 2 0 1 1 1 1 0 2 1 1 3 1 1 0 1 0 2...

output:

1812

result:

ok single line: '1812'

Test #207:

score: 5
Accepted
time: 778ms
memory: 789492kb

input:

4500
1 2 1 0 1 0 1 3 3 2 1 1 1 9 3 2 1 1 3 3 1 1 0 1 0 2 1 1 1 4 0 2 4 5 8 6 1 2 3 2 2 1 0 0 1 0 1 1 2 1 0 0 2 1 2 3 2 0 0 2 2 2 1 2 3 0 2 4 0 1 0 1 4 4 2 4 2 1 1 1 3 1 1 1 1 3 3 0 4 0 0 0 0 1 0 0 2 2 4 2 4 2 2 4 0 0 2 0 2 3 1 2 2 3 2 4 2 0 3 2 1 10 7 2 4 0 1 7 4 2 1 1 0 1 1 2 3 2 2 1 4 1 0 2 1 3 3 ...

output:

1773

result:

ok single line: '1773'

Test #208:

score: 5
Accepted
time: 740ms
memory: 717772kb

input:

3375
1 2 1 0 1 1 5 2 1 3 5 5 1 1 0 1 5 5 1 0 1 3 0 2 2 0 3 1 2 2 2 0 2 0 6 2 0 1 0 0 0 5 0 1 1 3 2 2 0 3 1 1 1 2 0 1 4 2 1 4 0 6 2 0 2 5 3 2 2 2 5 4 4 5 0 1 1 3 2 0 1 1 1 2 0 0 1 3 3 1 7 7 2 6 2 0 1 0 3 6 1 3 0 1 4 0 3 5 1 2 5 3 2 1 0 0 5 0 0 3 1 0 3 1 1 1 0 7 0 5 0 6 6 1 2 1 2 3 0 1 2 4 4 2 1 7 0 2...

output:

1831

result:

ok single line: '1831'

Test #209:

score: 5
Accepted
time: 687ms
memory: 664376kb

input:

2531
0 3 1 4 2 0 4 0 6 0 3 0 5 1 6 3 0 6 1 1 7 6 0 2 2 2 2 0 2 3 7 1 8 3 0 4 0 0 1 7 9 6 2 1 0 5 2 2 4 7 4 7 8 4 0 4 4 1 5 1 4 8 4 3 4 0 4 4 5 4 0 7 10 4 3 7 0 2 0 6 5 6 2 5 1 1 0 0 6 0 14 11 4 3 1 3 11 3 2 9 2 2 0 0 0 3 1 3 4 0 3 0 3 0 1 5 3 4 5 1 4 9 4 5 5 2 6 4 4 3 5 3 5 8 3 3 2 1 2 0 5 0 3 4 2 5...

output:

1751

result:

ok single line: '1751'

Test #210:

score: 5
Accepted
time: 650ms
memory: 625496kb

input:

1898
0 0 2 1 7 4 1 2 2 6 7 4 4 11 3 5 2 8 9 7 3 1 2 4 4 10 2 10 5 5 3 3 3 4 7 1 0 2 7 5 13 9 3 0 1 1 6 2 1 1 0 1 3 4 7 10 7 3 0 2 3 4 7 8 7 10 11 8 3 0 2 1 10 6 5 2 4 3 5 5 4 2 1 5 9 0 1 0 4 0 9 5 9 2 7 5 4 3 7 7 2 5 14 2 5 5 8 6 2 2 6 5 5 13 3 3 6 2 0 1 11 11 6 4 1 0 2 10 3 11 1 8 3 0 4 7 2 2 3 1 9...

output:

1672

result:

ok single line: '1672'

Test #211:

score: 5
Accepted
time: 623ms
memory: 596864kb

input:

1423
0 2 0 10 8 4 5 6 3 6 8 4 3 0 5 8 10 0 5 4 11 4 5 1 9 10 3 9 5 6 10 6 10 4 2 0 2 2 7 7 1 2 0 4 2 5 5 4 5 7 9 12 8 11 18 2 11 7 6 0 9 4 12 2 13 0 2 11 3 4 0 1 2 3 6 6 3 2 2 8 0 4 14 6 10 9 7 4 0 6 5 12 1 8 8 13 1 5 6 13 0 8 2 9 7 6 5 0 4 2 5 10 7 6 11 0 6 7 8 5 8 5 2 1 4 7 6 0 7 4 11 5 3 0 3 4 9 ...

output:

1785

result:

ok single line: '1785'

Test #212:

score: 5
Accepted
time: 619ms
memory: 570344kb

input:

1024
0 11 11 15 16 0 15 6 17 3 0 8 8 7 13 16 1 0 11 13 2 15 4 12 16 10 6 6 12 5 4 10 5 6 11 10 13 13 3 8 8 7 8 16 16 12 2 13 27 1 0 0 16 15 13 10 7 18 20 3 11 15 4 14 15 8 13 10 13 11 13 20 6 6 4 7 2 0 6 14 11 4 9 5 3 6 17 15 4 8 15 0 11 5 13 15 14 14 12 5 0 18 9 0 3 10 9 12 8 11 4 1 4 0 3 16 25 4 1...

output:

1696

result:

ok single line: '1696'

Test #213:

score: 5
Accepted
time: 582ms
memory: 537340kb

input:

512
1 21 2 0 14 0 10 10 0 19 17 1 20 10 23 18 0 12 14 13 10 10 11 3 28 1 35 27 9 17 23 33 16 12 6 9 29 23 16 29 25 14 32 16 28 1 32 10 23 27 2 4 28 20 22 18 5 27 24 16 19 5 27 26 14 27 16 3 21 21 10 13 6 29 31 41 29 28 19 5 28 29 35 29 23 16 22 25 8 14 17 13 27 11 13 25 22 24 27 2 18 18 21 19 5 38 2...

output:

1732

result:

ok single line: '1732'

Test #214:

score: 5
Accepted
time: 589ms
memory: 523076kb

input:

256
10 18 17 34 45 64 38 26 40 73 25 9 26 29 51 32 54 48 38 24 0 20 28 18 5 52 46 40 17 5 46 24 16 65 47 27 40 49 1 36 44 42 39 31 45 34 21 10 57 28 40 33 26 38 38 13 39 70 55 44 10 0 41 7 27 41 54 24 1 47 10 35 35 34 20 20 0 39 29 27 11 1 50 31 14 64 64 55 29 18 13 62 46 62 62 19 12 6 28 39 7 57 32...

output:

1487

result:

ok single line: '1487'

Test #215:

score: 5
Accepted
time: 583ms
memory: 514920kb

input:

128
35 41 68 103 42 19 121 120 22 22 122 100 94 64 46 26 112 85 37 98 42 89 23 41 15 127 68 51 72 20 70 3 111 56 112 86 8 45 135 30 4 101 50 18 15 70 41 86 24 10 0 109 13 1 36 90 27 109 17 15 113 59 116 85 58 23 31 69 5 97 95 102 52 20 13 112 106 105 93 8 9 114 68 99 1 44 66 78 39 57 64 129 82 57 92...

output:

1719

result:

ok single line: '1719'

Test #216:

score: 5
Accepted
time: 623ms
memory: 511052kb

input:

64
58 5 31 55 175 47 191 41 115 92 165 190 108 15 103 94 215 157 95 138 180 97 232 159 168 111 261 119 71 1 79 174 104 50 114 83 38 170 6 225 138 211 12 258 139 175 186 241 101 165 84 77 104 69 210 258 78 138 130 47 110 99 184 90
8000
25 38 31 35 34 62 48 3 53 58 38 6 13 5 31 30 22 52 8 41 2 63 35 3...

output:

1715

result:

ok single line: '1715'

Test #217:

score: 5
Accepted
time: 791ms
memory: 507172kb

input:

32
174 427 552 49 172 425 96 416 14 2 180 269 333 142 184 365 52 68 235 109 84 275 38 441 219 444 425 516 57 227 29 162
8000
19 28 11 22 20 23 14 9 20 16 23 11 12 25 20 7 30 29 6 9 13 8 4 23 28 28 29 19 26 27 22 12 7 28 16 5 16 31 8 22 21 28 19 15 24 11 23 3 26 12 14 1 26 10 5 31 13 8 11 24 17 1 9 2...

output:

2083

result:

ok single line: '2083'

Test #218:

score: 5
Accepted
time: 1400ms
memory: 507148kb

input:

16
118 606 419 620 1035 301 534 326 1011 809 545 457 189 410 160 118
8000
3 4 11 3 13 11 2 10 13 14 13 11 8 14 5 4 9 5 3 13 9 8 8 12 5 5 8 10 14 5 15 14 10 5 15 14 3 8 10 15 8 4 9 3 12 5 7 5 1 13 7 10 13 3 10 4 15 8 2 3 9 4 4 9 2 4 1 14 10 6 4 3 10 1 3 15 13 2 12 13 15 2 11 9 3 11 7 7 1 10 12 4 8 5 ...

output:

2032

result:

ok single line: '2032'

Test #219:

score: 0
Time Limit Exceeded

input:

8
240 295 695 1360 11 495 1293 588
8000
6 1 7 5 1 1 3 3 4 6 3 6 3 5 4 4 5 3 4 5 6 4 3 5 3 4 5 6 7 6 1 5 6 6 7 6 2 4 7 1 4 6 5 4 2 4 4 2 3 6 6 1 4 3 6 3 5 4 6 7 7 7 3 5 1 3 1 5 7 4 6 3 6 2 7 7 2 3 5 4 4 5 7 6 1 2 2 4 4 5 6 7 4 5 1 1 6 3 6 6 7 5 1 7 2 1 3 4 2 1 6 6 6 6 6 1 5 3 3 5 1 3 2 4 2 2 2 3 6 6 ...

output:


result: