QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#951045#10255. Thin Icerqoi031100 ✓358ms6444kbC++232.0kb2025-03-25 20:46:402025-03-25 20:46:40

Judging History

This is the latest submission verdict.

  • [2025-03-25 20:46:40]
  • Judged
  • Verdict: 100
  • Time: 358ms
  • Memory: 6444kb
  • [2025-03-25 20:46:40]
  • Submitted

answer

#include<stdio.h>
#include<algorithm>
#include<numeric>
#include<vector>
constexpr int N{200000};
int a[N+5],v[N+5],p[N+5];
int fa[N+5],size[N+5],tag[N+5];
inline int getf(const int &x) {
    return fa[x]==x?x:fa[x]=getf(fa[x]);
}
int main() {
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=0;i!=n*m;i++) {
        scanf("%d",a+i);
        v[i]=i<m||i>=(n-1)*m||i%m==0||(i+1)%m==0;
    }
    std::iota(p,p+n*m,0);
    std::sort(p,p+n*m,[&](const int &x,const int &y)->bool {
        return a[x]>a[y];
    });
    const auto check([&](const int &cnt)->bool {
        std::iota(fa,fa+n*m,0);
        std::fill(size,size+n*m,0);
        for(int i=0;i!=n*m;i++) {
            tag[i]=v[i]&&a[i]>=cnt;
        }
        const auto exec([&](const int &x,const int &y,const int &c)->void {
            if(size[y]) {
                int fy{getf(y)};
                if(fy!=x) {
                    tag[fy]&=size[fy]>=cnt-c;
                    fa[fy]=x,size[x]+=size[fy];
                    tag[x]|=tag[fy];
                }
            }
        });
        for(int i=cnt,j=0;i>=1;i--) {
            while(j!=n*m&&a[p[j]]>=i) {
                int &u{p[j]};
                size[u]=1;
                if(u>=m) {
                    exec(u,u-m,i);
                }
                if(u<(n-1)*m) {
                    exec(u,u+m,i);
                }
                if(u%m!=0) {
                    exec(u,u-1,i);
                }
                if((u+1)%m!=0) {
                    exec(u,u+1,i);
                }
                ++j;
            }
        }
        for(int i=0;i!=n*m;i++) {
            if(fa[i]==i&&tag[i]&&size[i]>=cnt) {
                return true;
            }
        }
        return false;
    });
    int l{1},r{n*m};
    while(l<=r) {
        int mid{l+r>>1};
        if(check(mid)) {
            l=mid+1;
        }
        else {
            r=mid-1;
        }
    }
    printf("%d\n",r);
    return 0;
}

詳細信息

Subtask #1:

score: 17
Accepted

Test #1:

score: 17
Accepted
time: 0ms
memory: 3824kb

input:

4 4
9 11 5 7
7 9 14 3
1 3 2 3
11 4 14 8

output:

10

result:

ok single line: '10'

Test #2:

score: 17
Accepted
time: 1ms
memory: 5864kb

input:

5 3
10 7 11
8 5 5
12 9 10
3 13 9
3 4 5

output:

10

result:

ok single line: '10'

Test #3:

score: 17
Accepted
time: 0ms
memory: 5860kb

input:

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

output:

8

result:

ok single line: '8'

Test #4:

score: 17
Accepted
time: 0ms
memory: 3820kb

input:

3 5
1 11 1 3 5
4 12 7 8 7
13 14 14 9 4

output:

14

result:

ok single line: '14'

Test #5:

score: 17
Accepted
time: 0ms
memory: 3816kb

input:

5 3
11 8 12
11 11 12
6 2 3
11 8 13
8 8 13

output:

12

result:

ok single line: '12'

Test #6:

score: 17
Accepted
time: 0ms
memory: 5864kb

input:

3 5
14 14 14 14 14
14 14 14 14 14
14 14 14 14 14

output:

14

result:

ok single line: '14'

Test #7:

score: 17
Accepted
time: 0ms
memory: 3816kb

input:

4 4
12 8 6 5
12 9 6 1
10 1 3 2
8 1 1 1

output:

12

result:

ok single line: '12'

Test #8:

score: 17
Accepted
time: 0ms
memory: 3816kb

input:

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

output:

13

result:

ok single line: '13'

Test #9:

score: 17
Accepted
time: 0ms
memory: 5856kb

input:

4 4
4 1 1 2
3 5 4 2
2 2 1 2
1 4 3 4

output:

4

result:

ok single line: '4'

Subtask #2:

score: 12
Accepted

Test #10:

score: 12
Accepted
time: 222ms
memory: 6376kb

input:

10 20000
5 3 2 1 3 2 3 3 4 5 1 1 2 3 5 4 3 4 5 5 5 4 5 2 5 4 2 4 5 1 1 1 4 2 2 2 1 3 5 2 5 5 3 5 5 4 3 1 3 3 4 3 3 5 4 5 4 4 1 2 5 5 4 4 4 5 2 2 1 2 5 1 5 3 2 5 4 5 2 3 1 2 3 3 4 2 3 2 5 3 1 2 5 3 2 3 2 2 4 4 5 2 5 1 1 2 2 2 4 3 3 2 2 1 2 4 1 2 4 4 3 2 4 5 2 4 5 5 4 5 5 2 2 2 5 1 3 5 4 3 2 4 5 2 1 3...

output:

5

result:

ok single line: '5'

Test #11:

score: 12
Accepted
time: 159ms
memory: 6400kb

input:

10 20000
1 2 1 2 1 2 1 2 1 1 1 1 2 1 1 2 2 2 1 1 1 1 1 1 1 1 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 2 1 1 1 1 1 1 1 1 2 1 2 1 2 1 1 1 1 1 1 2 2 1 1 2 1 2 1 1 1 1 2 2 2 1 3 1 1 1 1 1 1 2 2 1 1 1 1 2 1 1 1 1 1 1 1 3 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 2 1 1 1 1 1 3 1 1 1 1 1 1 1 2 1 1 1 1 1...

output:

3

result:

ok single line: '3'

Test #12:

score: 12
Accepted
time: 213ms
memory: 6368kb

input:

10 20000
3 2 2 3 1 2 1 4 4 3 1 4 3 2 4 3 2 2 2 1 3 1 1 2 1 3 4 2 1 3 3 2 2 2 2 3 2 3 3 3 2 3 3 3 3 1 2 3 2 5 2 2 2 4 2 3 3 3 3 4 3 3 2 1 3 1 2 1 3 2 2 1 1 1 3 1 3 5 3 3 3 3 2 2 1 3 1 1 3 2 4 2 4 3 2 1 2 3 2 2 2 2 4 1 2 3 2 2 2 2 1 2 3 2 1 3 3 1 4 3 2 2 1 1 1 3 4 2 2 5 2 2 3 1 2 2 3 4 1 2 4 2 2 3 3 3...

output:

5

result:

ok single line: '5'

Test #13:

score: 12
Accepted
time: 128ms
memory: 6332kb

input:

20000 10
1 1 3 1 2 1 1 1 1 1
1 2 2 1 1 1 1 2 1 1
2 1 1 1 2 2 1 1 1 2
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 2 1 1
1 1 1 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 1
2 2 1 1 1 1 1 1 1 1
1 1 1 1 2 1 1 1 1 2
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 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 1 1 1 1...

output:

4

result:

ok single line: '4'

Test #14:

score: 12
Accepted
time: 140ms
memory: 6412kb

input:

10 20000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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 #15:

score: 12
Accepted
time: 177ms
memory: 6376kb

input:

10 20000
3 1 3 1 2 1 2 3 2 2 1 2 1 1 2 2 2 1 1 1 1 2 2 1 1 2 2 2 2 1 1 2 2 2 2 2 1 2 1 1 2 1 2 2 2 2 2 2 2 2 1 2 1 3 2 2 2 2 2 2 1 3 1 1 1 2 2 1 2 2 2 2 2 2 2 1 1 2 2 2 2 2 1 1 1 2 2 2 2 1 2 2 1 2 1 2 2 1 1 2 4 1 1 1 2 2 1 2 1 2 1 2 2 2 2 1 2 2 2 2 1 2 2 1 1 1 3 2 2 2 2 2 1 1 1 1 2 1 2 2 1 1 2 2 2 1...

output:

3

result:

ok single line: '3'

Test #16:

score: 12
Accepted
time: 208ms
memory: 6376kb

input:

10 20000
1 2 2 2 1 2 3 1 2 2 2 1 2 2 2 1 1 2 2 1 2 1 2 2 1 2 1 2 1 1 2 2 2 2 2 2 3 1 2 2 1 1 1 1 2 2 1 1 1 2 1 1 1 2 1 2 2 2 2 1 3 2 1 2 2 3 2 2 1 2 3 2 1 2 1 1 3 2 1 2 1 1 2 2 2 3 1 2 1 2 1 2 2 2 2 1 2 1 1 2 2 1 1 1 1 1 1 2 2 1 1 2 2 2 2 1 3 1 2 2 1 2 2 1 2 1 1 2 2 2 2 2 1 3 2 1 1 1 1 2 1 1 1 1 2 1...

output:

4

result:

ok single line: '4'

Test #17:

score: 12
Accepted
time: 208ms
memory: 6412kb

input:

10 20000
3 3 2 3 2 3 2 2 2 2 2 1 3 2 1 1 2 2 1 2 1 1 3 2 3 1 3 1 2 3 1 1 2 2 2 2 2 3 1 3 1 2 3 3 2 3 2 3 1 2 2 1 3 2 2 3 3 1 1 1 3 1 1 3 3 2 3 3 1 2 2 2 2 1 2 1 1 3 2 2 3 3 1 3 2 3 1 2 3 2 3 1 1 2 2 3 3 1 1 1 3 3 1 3 1 1 2 2 2 3 3 1 2 1 1 3 1 3 2 3 1 3 2 2 2 1 3 2 2 2 3 2 2 1 2 2 3 1 1 1 2 1 3 2 2 3...

output:

4

result:

ok single line: '4'

Test #18:

score: 12
Accepted
time: 215ms
memory: 6236kb

input:

10 20000
1 3 3 1 1 4 3 3 3 1 2 2 1 3 1 2 1 2 2 1 3 1 2 2 2 2 1 3 1 1 2 2 3 3 3 3 2 4 2 3 2 3 3 2 1 1 3 3 2 2 3 1 2 2 3 2 2 5 2 2 2 4 3 2 3 3 2 1 2 3 4 2 3 3 1 2 3 3 2 1 1 2 1 3 1 1 1 2 3 1 1 3 2 1 1 3 1 1 2 3 3 2 4 1 2 3 1 2 2 3 2 1 1 2 2 2 3 1 1 2 2 2 3 3 1 2 1 1 2 1 2 1 1 1 2 3 1 1 4 1 1 1 1 2 2 3...

output:

5

result:

ok single line: '5'

Test #19:

score: 12
Accepted
time: 116ms
memory: 6400kb

input:

7 28571
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 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:

3

result:

ok single line: '3'

Test #20:

score: 12
Accepted
time: 137ms
memory: 6376kb

input:

28571 7
4 4 4 4 4 4 4
4 4 4 4 4 4 4
4 4 4 4 4 4 4
4 4 4 4 4 4 4
4 4 4 4 4 4 4
4 4 4 4 4 4 4
4 4 4 4 4 4 4
4 4 4 4 5 4 4
4 4 4 4 5 4 4
4 4 4 4 4 4 4
4 4 4 4 4 4 4
4 4 4 4 4 4 4
4 4 4 4 4 4 4
4 4 4 4 4 4 4
4 4 4 4 4 4 4
4 4 4 4 4 4 4
4 4 4 4 4 4 4
4 4 4 4 4 4 4
4 4 4 4 4 4 4
4 4 4 4 4 4 4
4 4 4 4 4 4 ...

output:

5

result:

ok single line: '5'

Test #21:

score: 12
Accepted
time: 122ms
memory: 6444kb

input:

447 447
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 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:

3

result:

ok single line: '3'

Subtask #3:

score: 11
Accepted

Test #22:

score: 11
Accepted
time: 0ms
memory: 5860kb

input:

1 100
46 23 23 55 37 17 30 32 25 71 79 43 82 100 41 79 3 91 61 2 63 30 66 87 86 25 59 50 71 77 49 90 69 67 12 7 19 18 70 21 37 35 43 82 40 65 65 58 42 53 17 81 51 68 52 52 35 41 31 55 23 95 6 31 75 13 31 70 98 70 37 50 50 29 76 82 51 28 13 8 82 39 37 47 25 3 81 43 24 78 26 66 44 60 84 26 65 60 72 83

output:

30

result:

ok single line: '30'

Test #23:

score: 11
Accepted
time: 0ms
memory: 3820kb

input:

1 100
8 13 12 11 15 15 15 19 18 21 25 26 31 30 35 36 33 41 42 48 52 51 52 53 54 55 60 59 54 51 49 46 45 48 41 45 47 47 54 51 54 54 56 59 59 63 62 63 57 57 54 52 53 52 55 57 57 60 62 64 62 64 68 68 71 72 72 77 75 78 72 70 68 66 61 61 56 56 60 59 59 60 64 65 66 64 68 65 68 71 72 71 73 76 74 77 79 73 6...

output:

76

result:

ok single line: '76'

Test #24:

score: 11
Accepted
time: 0ms
memory: 3820kb

input:

1 100
94 94 94 95 95 91 97 100 92 98 98 87 91 91 91 91 96 96 91 95 94 93 95 95 74 93 98 93 95 95 91 94 94 93 95 93 93 88 97 97 95 95 95 89 94 92 97 92 92 92 57 95 95 86 92 97 70 91 84 97 84 84 89 70 96 96 83 83 88 70 92 92 86 86 95 70 98 99 94 94 94 97 85 90 94 85 85 85 70 83 83 83 83 93 83 83 83 83...

output:

95

result:

ok single line: '95'

Test #25:

score: 11
Accepted
time: 1ms
memory: 5856kb

input:

1 100
83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 ...

output:

83

result:

ok single line: '83'

Test #26:

score: 11
Accepted
time: 0ms
memory: 5856kb

input:

1 100
33 34 35 38 38 40 41 42 42 45 47 48 57 57 59 61 63 68 69 70 70 73 74 75 84 87 88 92 93 95 94 92 90 92 86 85 83 83 81 80 79 78 78 76 72 71 67 65 64 62 61 59 55 54 53 52 51 50 49 46 44 44 36 32 31 31 29 28 27 26 25 25 23 22 21 21 19 18 19 16 15 15 14 12 11 11 9 8 7 7 6 4 3 2 1 2 1 1 2 1

output:

95

result:

ok single line: '95'

Test #27:

score: 11
Accepted
time: 0ms
memory: 5860kb

input:

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

output:

29

result:

ok single line: '29'

Subtask #4:

score: 19
Accepted

Dependency #3:

100%
Accepted

Test #28:

score: 19
Accepted
time: 110ms
memory: 6400kb

input:

1 200000
138736 14949 12344 104147 133323 9071 111842 195859 17023 87343 78484 42110 99416 73098 66430 30151 68468 58188 73128 138856 170126 7725 89700 179125 63295 158303 72347 11080 90145 59232 183054 15987 91992 146829 54736 12206 183500 53603 91907 170341 108919 177542 138139 97674 166168 192052...

output:

1806

result:

ok single line: '1806'

Test #29:

score: 19
Accepted
time: 109ms
memory: 6404kb

input:

1 200000
141245 141090 141163 141286 141147 141292 141154 141353 141241 141300 141277 141283 141204 141418 141237 141206 141123 141284 141215 141076 141281 141187 141153 141266 141168 141294 141257 141308 141301 141196 141422 141292 141293 141275 141280 141399 141177 141309 141335 141310 141190 1412...

output:

155109

result:

ok single line: '155109'

Test #30:

score: 19
Accepted
time: 108ms
memory: 6428kb

input:

1 200000
102358 102469 102440 102402 102472 102512 102517 102424 102391 102457 102465 102486 102613 102515 102554 102504 102457 102476 102549 102548 102577 102537 102472 102587 102584 102537 102524 102530 102499 102488 102616 102583 102514 102676 102491 102584 102614 102548 102575 102522 102480 1025...

output:

152388

result:

ok single line: '152388'

Test #31:

score: 19
Accepted
time: 101ms
memory: 6380kb

input:

1 200000
180410 160820 160820 180614 180614 160820 180277 190055 160820 180431 180431 160820 197641 195270 190308 190308 190308 180442 190147 190147 180442 190259 190259 160811 180343 180343 180343 195061 190134 160825 160825 180491 160825 190123 180385 160822 160824 160824 160824 160824 160824 1608...

output:

160832

result:

ok single line: '160832'

Test #32:

score: 19
Accepted
time: 50ms
memory: 6372kb

input:

1 200000
198270 198270 198270 198270 198270 198270 198270 198270 198270 198270 198270 198270 198270 198270 198270 198270 198270 198270 198270 198270 198270 198270 198270 198270 198270 198270 198270 198270 198270 198270 198270 198270 198270 198270 198270 198270 198270 198270 198270 198270 198270 1982...

output:

198270

result:

ok single line: '198270'

Test #33:

score: 19
Accepted
time: 56ms
memory: 6376kb

input:

1 200000
1 1 3 2 1 1 2 3 6 6 6 7 8 9 10 11 12 13 15 16 16 17 18 19 21 21 22 24 25 25 26 27 28 29 30 32 32 33 34 35 36 37 38 39 42 42 42 43 45 45 46 47 49 50 50 51 52 53 54 55 57 58 58 60 60 61 62 63 65 65 66 67 68 70 71 71 72 73 74 75 76 77 78 79 81 82 82 83 84 86 86 87 88 90 90 91 92 93 94 95 96 97...

output:

199995

result:

ok single line: '199995'

Test #34:

score: 19
Accepted
time: 110ms
memory: 6380kb

input:

1 200000
14737 162555 44228 170991 134006 137046 20849 4979 180481 118962 169841 146138 161902 40853 63223 15374 190028 112463 34522 106149 54529 19313 3463 112322 88712 11933 119322 72152 131284 128284 122947 18509 153644 166311 35753 68697 1810 85652 186321 11936 177518 199607 174779 198005 149335...

output:

1902

result:

ok single line: '1902'

Subtask #5:

score: 14
Accepted

Dependency #1:

100%
Accepted

Test #35:

score: 14
Accepted
time: 0ms
memory: 3816kb

input:

31 32
669 792 226 189 860 737 291 839 149 842 13 237 777 932 405 618 856 279 539 918 510 247 376 173 173 385 153 650 925 488 36 773
847 873 638 191 500 669 970 643 656 890 690 701 724 494 431 502 192 232 794 313 967 22 103 973 326 270 140 21 828 875 943 217
451 982 569 746 521 203 998 791 222 247 80...

output:

565

result:

ok single line: '565'

Test #36:

score: 14
Accepted
time: 1ms
memory: 3812kb

input:

10 100
730 698 339 743 536 702 94 556 725 671 228 509 608 872 991 574 448 57 734 22 83 524 530 919 989 975 85 913 694 441 484 928 658 43 627 172 597 697 209 631 16 799 500 26 314 35 694 929 356 445 114 843 196 620 54 917 597 597 222 414 239 248 678 582 391 865 579 840 894 554 105 585 54 715 542 967 ...

output:

529

result:

ok single line: '529'

Test #37:

score: 14
Accepted
time: 0ms
memory: 5860kb

input:

32 31
633 613 618 605 635 638 668 675 677 684 678 639 652 622 576 601 501 589 566 554 521 451 229 228 165 47 26 21 17 19 27
631 621 621 624 620 634 612 678 660 685 647 664 649 638 634 607 587 594 437 507 460 435 428 348 191 165 166 130 41 16 23
639 640 634 631 624 646 654 672 652 682 688 665 651 644...

output:

678

result:

ok single line: '678'

Test #38:

score: 14
Accepted
time: 0ms
memory: 3816kb

input:

142 7
983 930 963 926 979 962 962
966 930 963 924 928 928 926
926 929 929 922 931 931 978
929 929 929 922 959 928 964
921 893 900 884 893 905 896
933 929 967 928 984 964 964
933 930 967 922 930 930 930
934 931 967 929 967 930 963
852 884 879 838 869 880 877
934 933 974 926 969 928 928
933 929 933 91...

output:

934

result:

ok single line: '934'

Test #39:

score: 14
Accepted
time: 0ms
memory: 5864kb

input:

31 32
977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977
977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977 977
977 977 977 977 977 977 977 977 977 97...

output:

977

result:

ok single line: '977'

Test #40:

score: 14
Accepted
time: 0ms
memory: 5860kb

input:

50 20
1 27 14 23 38 48 56 3 12 9 6 27 33 59 91 68 57 32 9 1
30 26 4 2 10 49 74 58 37 17 1 28 41 78 93 44 13 18 2 23
51 29 15 7 75 52 84 56 31 6 20 36 40 100 94 145 77 16 20 45
61 49 34 24 87 69 98 105 63 11 21 43 109 103 148 165 166 85 82 51
68 71 88 92 119 83 128 151 39 37 81 108 116 95 138 124 177...

output:

997

result:

ok single line: '997'

Test #41:

score: 14
Accepted
time: 1ms
memory: 3816kb

input:

20 50
481 532 624 290 965 58 448 872 773 585 451 156 841 118 843 468 67 537 912 230 882 995 731 287 77 15 886 159 792 668 472 264 386 366 215 877 721 954 381 99 515 715 594 115 674 50 49 368 354 825
738 163 651 232 694 631 885 506 509 851 577 652 273 689 443 567 519 237 72 796 200 621 834 853 630 63...

output:

504

result:

ok single line: '504'

Subtask #6:

score: 27
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Dependency #5:

100%
Accepted

Test #42:

score: 27
Accepted
time: 343ms
memory: 6376kb

input:

447 447
6474 27185 108482 124481 160584 151716 11032 162301 76453 123035 42195 111219 170471 124503 23715 93818 2524 144301 23631 100208 54858 59289 179906 144021 45627 194509 197819 121622 16352 10629 60155 23638 184284 123486 197482 55571 10240 59054 20700 45828 151183 57429 69728 42700 193243 379...

output:

88202

result:

ok single line: '88202'

Test #43:

score: 27
Accepted
time: 358ms
memory: 6228kb

input:

1000 200
27722 57131 197677 184858 92854 31399 197006 160398 31855 184923 825 20182 127057 86459 80911 178693 138903 98891 49077 188805 97477 165889 9197 130373 131841 133750 96520 25218 38936 27555 116364 58254 2984 8150 162201 7737 985 134943 187189 106062 22001 91159 112817 15179 50548 163841 194...

output:

89324

result:

ok single line: '89324'

Test #44:

score: 27
Accepted
time: 301ms
memory: 6400kb

input:

447 447
70928 73154 72640 74764 75237 75550 75876 76674 72904 75156 76409 76898 76461 75499 71974 76536 76461 76412 73284 77564 77643 74041 75317 76361 76367 75672 73120 73643 76123 76276 74700 75150 74531 71338 73333 74911 75785 75899 76729 78755 78989 78522 78887 79273 79688 80243 80302 80072 7769...

output:

181096

result:

ok single line: '181096'

Test #45:

score: 27
Accepted
time: 171ms
memory: 6416kb

input:

7 28571
193031 185883 171670 185794 171673 185970 171637 196362 192879 171660 185937 185937 192990 171537 171676 185964 171674 185961 171675 192953 171631 192926 196459 171660 185936 185936 185936 171504 192891 196392 171670 185764 171670 192867 171616 185849 171674 185819 171670 192796 185650 17160...

output:

171680

result:

ok single line: '171680'

Test #46:

score: 27
Accepted
time: 117ms
memory: 6192kb

input:

10 20000
191628 191628 191628 191628 191628 191628 191628 191628 191628 191628 191628 191628 191628 191628 191628 191628 191628 191628 191628 191628 191628 191628 191628 191628 191628 191628 191628 191628 191628 191628 191628 191628 191628 191628 191628 191628 191628 191628 191628 191628 191628 1916...

output:

191628

result:

ok single line: '191628'

Test #47:

score: 27
Accepted
time: 289ms
memory: 6376kb

input:

200 1000
3550 2640 3791 4248 4257 4504 4533 4634 4655 4749 5564 5321 5595 5949 6124 6465 6517 6236 6281 6883 7071 7043 7622 8139 8444 8571 8750 8656 8723 8863 8926 9050 9535 10132 10260 9912 9876 10436 10669 11058 11433 11535 11785 12119 12171 12449 12647 12709 12783 13106 13811 14421 14803 14996 14...

output:

199997

result:

ok single line: '199997'

Test #48:

score: 27
Accepted
time: 331ms
memory: 6404kb

input:

1000 200
198379 62425 88013 50967 49098 79116 88158 188990 28849 159805 53861 174496 97302 153583 182150 73245 36643 87022 68306 111411 149136 90121 99571 45007 2355 151248 121871 173578 171145 138078 119798 55814 71449 146955 92113 161630 95989 188898 88492 72528 5043 183998 30673 83462 171038 1597...

output:

89131

result:

ok single line: '89131'