QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#827034#9907. 最大匹配 2 hhoppitree#45 1357ms69572kbC++174.0kb2024-12-22 18:44:432024-12-22 18:44:44

Judging History

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

  • [2024-12-22 18:44:44]
  • 评测
  • 测评结果:45
  • 用时:1357ms
  • 内存:69572kb
  • [2024-12-22 18:44:43]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

const int N = 2e5 + 5;

int n, m, a[N], b[N], c1[1 << 19], c2[1 << 19];

void pushup(int k) {
    c1[k] = c1[k << 1], c2[k] = c2[k << 1 | 1];
    if (c2[k << 1] > c1[k << 1 | 1]) c2[k] += c2[k << 1] - c1[k << 1 | 1];
    else c1[k] += c1[k << 1 | 1] - c2[k << 1];
}

void build(int k, int l, int r) {
    if (l == r) {
        if (b[k] == 0) c2[k] = 1;
        else c1[k] = 1;
        return;
    }
    int mid = (l + r) >> 1;
    build(k << 1, l, mid), build(k << 1 | 1, mid + 1, r);
    pushup(k);
}

void modify(int k, int l, int r, int x, int y) {
    if (l == r) {
        c1[k] = c2[k] = 0;
        if (y == -1) c2[k] = 1;
        else if (y == 1) c1[k] = 1;
        return;
    }
    int mid = (l + r) >> 1;
    if (x <= mid) modify(k << 1, l, mid, x, y);
    else modify(k << 1 | 1, mid + 1, r, x, y);
    pushup(k);
}

struct Info {
    int s, ls, rs, lm, rm;
} p[N << 6];

Info operator + (Info x, Info y) {
    Info res;
    res.s = x.s + y.s;
    res.lm = max(x.lm, x.s + y.lm);
    res.rm = max(y.rm, -y.s + x.rm);
    return res;
}

int rt[N], tot;

void Modify(int &k, int l, int r, int x, int y) {
    if (!k) k = ++tot;
    if (l == r) {
        p[k].s = y;
        p[k].lm = max(y, 0);
        p[k].rm = max(-y, 0);
        return;
    }
    int mid = (l + r) >> 1;
    if (x <= mid) Modify(p[k].ls, l, mid, x, y);
    else Modify(p[k].rs, mid + 1, r, x, y);
    int tl = p[k].ls, tr = p[k].rs;
    p[k] = p[p[k].ls] + p[p[k].rs];
    p[k].ls = tl, p[k].rs = tr;
}

Info Query(int k, int l, int r, int x, int y) {
    if (!k || l > y || r < x) return p[0];
    if (l >= x && r <= y) return p[k];
    int mid = (l + r) >> 1;
    return Query(p[k].ls, l, mid, x, y) + Query(p[k].rs, mid + 1, r, x, y);
}

vector< pair<int, int> > glo;

int findLst(int k, int l, int r, int y, int val) {
    int L = 1, R = y, res;
    while (L <= R) {
        int mid = (L + R) >> 1;
        if (Query(k, l, r, mid, y).rm >= val) res = mid, L = mid + 1;
        else R = mid - 1;
    }
    return res;
}

int findNxt(int k, int l, int r, int x, int val) {
    int L = x, R = n, res;
    while (L <= R) {
        int mid = (L + R) >> 1;
        if (Query(k, l, r, x, mid).lm >= val) res = mid, R = mid - 1;
        else L = mid + 1;
    }
    return res;
}

void test(int x) {
    Info L = Query(rt[a[x]], 1, n, 1, x - 1), R = Query(rt[a[x]], 1, n, x + 1, n);
    if (b[x] == 0) {
        if (R.lm != 0) {
            glo.push_back({x, 1});
            if (L.rm >= R.lm) {
                glo.push_back({findLst(rt[a[x]], 1, n, x - 1, R.lm), 0});
            } else {
                glo.push_back({findNxt(rt[a[x]], 1, n, x + 1, L.rm + 1), 1});
            }
        } else {
            glo.push_back({x, 0});
        }
    } else {
        if (L.rm != 0) {
            glo.push_back({x, 1});
            if (R.lm >= L.rm) {
                glo.push_back({findNxt(rt[a[x]], 1, n, x + 1, L.rm), 0});
            } else {
                glo.push_back({findLst(rt[a[x]], 1, n, x - 1, R.lm + 1), 1});
            }
        } else {
            glo.push_back({x, 0});
        }
    }
}

void erase(int x) {
    Modify(rt[a[x]], 1, n, x, 0);
    glo.clear(), test(x);
    for (auto [x, y] : glo) modify(1, 1, n, x, (y != 0 ? (b[x] == 0 ? -1 : 1) : 0));
}

void insert(int x) {
    glo.clear(), test(x);
    Modify(rt[a[x]], 1, n, x, b[x] == 0 ? -1 : 1);
    for (auto [x, y] : glo) modify(1, 1, n, x, (y != 0 ? 0 : (b[x] == 0 ? -1 : 1)));
}

signed main() {
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
    for (int i = 1; i <= n; ++i) scanf("%d", &b[i]);
    build(1, 1, n);
    for (int i = 1; i <= n; ++i) insert(i);
    printf("%d\n", (n - c1[1] - c2[1]) / 2);
    while (m--) {
        int p, q, r; scanf("%d%d%d", &p, &q, &r);
        erase(p);
        a[p] = q, b[p] = r;
        insert(p);
        printf("%d\n", (n - c1[1] - c2[1]) / 2);
    }
    return 0;
}

详细

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 1ms
memory: 7940kb

input:

100 0
1 1 2 1 2 2 2 2 2 1 2 1 1 2 2 1 2 2 2 2 2 1 1 2 2 2 1 2 2 2 2 1 2 2 2 2 2 2 2 2 2 1 2 2 2 2 2 2 1 1 2 1 2 1 1 1 2 2 2 2 2 2 1 1 1 2 1 1 1 1 1 2 2 1 1 2 1 1 2 1 1 2 2 2 1 2 2 2 1 2 1 2 1 2 1 1 2 1 1 2
1 1 0 1 0 0 0 0 1 1 0 1 0 1 0 1 1 1 1 0 0 0 1 0 0 0 1 1 0 0 0 0 0 1 1 0 1 1 0 0 0 0 1 1 1 1 1 ...

output:

45

result:

ok "45"

Test #2:

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

input:

100 0
2 1 1 2 1 2 1 2 1 1 1 2 1 1 2 1 1 2 2 1 2 1 2 2 1 1 2 2 1 1 1 2 1 1 1 2 2 1 2 1 1 2 2 2 2 2 1 2 1 2 2 1 1 2 1 2 2 1 1 2 2 1 1 1 2 2 1 2 1 2 1 2 2 2 1 2 1 1 2 2 2 2 1 1 1 1 1 1 1 2 2 1 2 1 2 2 2 2 1 2
0 0 0 1 1 1 1 1 0 1 1 0 1 0 0 1 1 1 1 0 0 1 1 0 0 1 0 0 1 0 0 1 0 1 0 0 1 1 0 1 1 0 1 1 1 1 0 ...

output:

43

result:

ok "43"

Test #3:

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

input:

100 0
2 2 3 3 4 4 3 2 4 4 1 2 3 4 3 4 4 3 3 2 3 1 2 4 1 3 1 4 3 3 4 4 3 3 1 4 1 1 2 2 1 3 4 3 3 4 3 3 4 3 4 3 4 4 1 1 1 4 3 1 2 1 2 3 3 3 2 1 1 1 1 3 3 2 4 2 3 4 1 4 1 4 1 1 2 1 1 1 1 1 4 4 2 3 2 1 2 3 1 4
1 1 1 1 1 1 1 1 0 1 1 0 1 1 1 1 1 0 1 0 0 0 1 0 1 1 0 0 1 0 1 1 1 1 0 1 1 1 0 1 0 1 1 1 0 0 1 ...

output:

37

result:

ok "37"

Test #4:

score: 10
Accepted
time: 1ms
memory: 7980kb

input:

100 0
3 1 2 4 3 2 2 1 4 2 2 3 2 1 1 2 3 3 2 3 1 1 3 4 3 2 1 2 4 3 4 2 2 1 2 4 2 2 1 1 3 3 1 2 3 4 3 2 3 2 2 1 3 3 1 2 3 2 2 3 3 4 2 2 1 4 1 3 2 3 3 4 4 3 2 1 4 2 2 3 4 2 3 2 3 4 3 3 1 2 3 4 3 1 4 1 2 2 2 3
1 0 1 1 0 1 1 0 0 0 0 0 0 1 1 1 0 1 1 0 0 0 0 1 0 1 0 0 0 1 1 1 0 0 1 1 0 0 1 1 1 0 0 0 0 0 0 ...

output:

44

result:

ok "44"

Test #5:

score: 10
Accepted
time: 1ms
memory: 7976kb

input:

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

output:

37

result:

ok "37"

Test #6:

score: 10
Accepted
time: 1ms
memory: 7892kb

input:

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

output:

39

result:

ok "39"

Test #7:

score: 10
Accepted
time: 1ms
memory: 7888kb

input:

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

output:

37

result:

ok "37"

Test #8:

score: 10
Accepted
time: 1ms
memory: 8004kb

input:

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

output:

35

result:

ok "35"

Test #9:

score: 10
Accepted
time: 1ms
memory: 8044kb

input:

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

output:

38

result:

ok "38"

Test #10:

score: 10
Accepted
time: 1ms
memory: 6000kb

input:

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

output:

44

result:

ok "44"

Subtask #2:

score: 15
Accepted

Test #11:

score: 15
Accepted
time: 0ms
memory: 8044kb

input:

2000 0
2 2 1 1 2 1 2 2 2 1 1 1 2 1 2 2 1 2 2 1 2 1 2 1 1 2 1 2 2 1 2 2 2 1 1 1 1 1 1 2 1 1 2 2 1 2 1 2 2 2 1 1 2 1 1 1 2 2 2 2 2 2 1 1 2 1 1 2 2 1 2 1 1 1 1 2 1 1 1 1 1 2 2 2 2 1 2 2 1 2 2 2 2 2 1 2 1 2 1 1 2 1 1 2 2 1 1 1 1 1 1 1 1 2 2 1 2 2 2 2 2 1 1 2 2 2 2 1 2 2 2 1 1 1 2 1 2 1 1 1 2 2 1 2 1 1 1...

output:

954

result:

ok "954"

Test #12:

score: 15
Accepted
time: 3ms
memory: 8028kb

input:

2000 0
2 1 1 1 1 1 2 2 2 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 2 2 1 2 1 1 1 1 1 1 1 2 2 1 2 2 1 1 2 2 2 2 1 2 2 2 2 1 1 2 2 1 1 1 2 2 1 2 1 2 2 2 1 2 2 1 2 2 2 2 2 1 2 1 2 2 1 2 2 1 1 1 1 1 2 2 1 2 1 2 1 2 1 1 1 2 2 2 1 2 1 1 2 1 2 1 1 1 1 1 2 1 2 1 2 2 2 2 1 2 1 1 2 2 2 2 1 1 2 2 1 1 2 1 2 2 2...

output:

958

result:

ok "958"

Test #13:

score: 15
Accepted
time: 0ms
memory: 6104kb

input:

2000 0
4 3 4 4 2 2 2 2 3 1 1 3 1 3 3 3 1 4 2 2 2 4 4 3 3 3 1 1 3 1 2 1 2 1 1 4 1 2 2 4 3 3 1 3 2 2 1 3 2 1 3 4 3 2 3 4 3 1 3 2 2 1 4 2 4 4 3 4 1 3 3 1 3 1 3 1 4 3 4 4 4 3 4 1 3 2 4 3 4 3 1 3 2 4 1 4 2 1 2 2 4 4 1 4 2 4 1 1 1 2 1 1 4 1 1 2 2 1 4 2 2 3 4 2 2 3 1 4 1 1 2 2 1 3 2 1 3 2 3 3 1 1 2 4 1 1 4...

output:

946

result:

ok "946"

Test #14:

score: 15
Accepted
time: 0ms
memory: 8116kb

input:

2000 0
1 2 4 3 3 3 2 3 1 4 4 1 4 4 1 2 3 4 2 3 1 2 1 4 3 4 3 3 4 3 4 4 1 4 4 2 4 4 2 1 2 3 2 3 2 4 2 2 3 4 3 3 4 3 4 4 4 4 2 2 4 3 4 3 1 3 3 2 2 2 4 3 1 1 2 1 2 2 2 1 1 2 1 4 2 3 4 1 4 1 1 4 1 2 1 1 4 4 3 2 4 1 2 1 1 1 1 2 4 2 2 3 4 1 1 4 2 2 4 3 3 1 2 3 2 1 4 2 2 1 4 2 2 4 3 3 1 2 2 3 4 3 1 4 3 1 1...

output:

945

result:

ok "945"

Test #15:

score: 15
Accepted
time: 0ms
memory: 8172kb

input:

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

output:

947

result:

ok "947"

Test #16:

score: 15
Accepted
time: 3ms
memory: 6116kb

input:

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

output:

948

result:

ok "948"

Test #17:

score: 15
Accepted
time: 3ms
memory: 8252kb

input:

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

output:

949

result:

ok "949"

Test #18:

score: 15
Accepted
time: 3ms
memory: 8068kb

input:

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

output:

928

result:

ok "928"

Test #19:

score: 15
Accepted
time: 2ms
memory: 6200kb

input:

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

output:

950

result:

ok "950"

Test #20:

score: 15
Accepted
time: 3ms
memory: 8072kb

input:

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

output:

918

result:

ok "918"

Test #21:

score: 15
Accepted
time: 0ms
memory: 8220kb

input:

2000 0
29 39 61 16 16 45 3 35 24 19 61 12 42 36 49 32 58 54 27 17 11 47 59 3 47 37 41 13 30 39 37 46 60 48 9 63 12 3 8 3 49 9 26 64 36 42 56 47 33 54 40 47 19 17 48 56 44 38 32 61 15 51 7 11 57 19 15 22 42 2 23 19 48 28 47 55 34 49 9 21 56 38 63 29 5 25 30 62 49 62 21 58 59 3 19 4 61 4 48 45 33 6 14...

output:

909

result:

ok "909"

Test #22:

score: 15
Accepted
time: 3ms
memory: 8276kb

input:

2000 0
28 13 36 62 2 58 55 9 2 14 56 45 12 61 21 52 29 6 12 48 20 43 37 41 7 47 64 23 15 12 7 42 15 31 43 7 64 30 11 3 7 17 13 46 49 6 47 10 55 17 33 37 9 52 63 28 45 27 25 53 55 51 34 23 41 31 18 11 31 37 18 45 45 31 27 58 29 12 16 44 19 45 64 55 7 20 31 27 34 35 11 63 57 17 2 34 1 54 20 37 55 4 11...

output:

900

result:

ok "900"

Test #23:

score: 15
Accepted
time: 2ms
memory: 8308kb

input:

2000 0
31 104 15 67 66 31 37 55 12 115 95 50 47 3 115 11 25 8 40 43 117 107 99 3 9 75 111 115 74 97 24 8 16 86 71 59 43 25 63 121 125 19 109 83 105 62 20 65 17 57 47 51 69 18 114 18 97 96 114 5 68 74 125 5 33 85 75 73 110 75 95 104 104 28 127 89 22 30 88 9 69 43 110 32 104 1 116 52 127 121 35 15 85 ...

output:

872

result:

ok "872"

Test #24:

score: 15
Accepted
time: 2ms
memory: 8184kb

input:

2000 0
11 44 53 57 20 98 36 75 12 56 9 94 7 128 42 27 3 95 19 97 109 35 114 115 4 9 34 104 63 29 65 60 50 36 98 53 67 12 117 75 116 78 45 36 78 48 63 23 121 16 126 12 112 78 100 60 44 48 85 108 3 38 94 21 67 54 14 116 27 50 114 68 17 3 81 64 96 5 50 65 33 122 102 100 33 101 44 114 66 80 99 44 121 11...

output:

883

result:

ok "883"

Test #25:

score: 15
Accepted
time: 2ms
memory: 8284kb

input:

2000 0
212 40 232 87 79 203 233 171 143 9 124 97 47 54 250 185 169 100 244 253 120 131 85 195 8 234 73 7 171 247 118 184 64 132 82 42 64 116 53 137 155 33 87 164 160 6 168 102 125 31 63 39 229 76 16 65 100 244 26 83 73 232 85 146 135 196 233 175 96 240 214 248 208 164 128 8 29 60 103 140 214 151 114...

output:

852

result:

ok "852"

Test #26:

score: 15
Accepted
time: 2ms
memory: 8348kb

input:

2000 0
228 227 120 56 250 38 238 224 14 1 239 70 20 90 235 248 114 33 47 210 111 244 218 72 51 144 243 191 168 149 165 105 89 224 147 217 17 46 79 207 48 94 182 80 209 145 45 40 47 255 3 118 55 96 6 172 35 130 26 116 40 68 68 102 184 92 10 94 52 66 53 237 6 189 28 16 106 208 50 33 68 24 249 191 102 ...

output:

863

result:

ok "863"

Test #27:

score: 15
Accepted
time: 2ms
memory: 8308kb

input:

2000 0
510 427 155 433 37 348 174 418 481 8 170 485 274 110 187 213 285 60 125 460 135 101 299 75 83 33 268 169 125 472 46 363 60 155 232 365 4 213 384 468 6 404 133 201 483 251 129 319 129 505 71 261 251 76 460 122 65 387 507 149 432 372 200 243 499 394 440 239 284 93 298 154 35 416 156 474 494 116...

output:

866

result:

ok "866"

Test #28:

score: 15
Accepted
time: 2ms
memory: 8340kb

input:

2000 0
354 297 56 124 319 256 97 329 474 344 18 227 225 116 272 259 287 6 411 222 281 145 104 62 84 239 320 231 424 262 323 232 278 142 84 288 11 323 322 482 405 108 223 168 381 137 191 8 15 466 220 360 450 109 109 243 226 340 504 102 371 197 219 6 174 248 314 401 4 396 69 179 158 18 294 197 412 498...

output:

864

result:

ok "864"

Test #29:

score: 15
Accepted
time: 0ms
memory: 8396kb

input:

2000 0
393 713 332 785 736 132 371 355 885 858 647 475 461 236 796 95 786 256 736 260 862 1020 895 868 364 1018 75 856 217 269 567 759 553 133 647 397 651 167 171 651 1006 5 833 305 300 578 438 242 790 902 810 973 625 232 838 205 231 796 453 274 851 632 111 269 885 482 875 156 558 218 384 382 110 75...

output:

859

result:

ok "859"

Test #30:

score: 15
Accepted
time: 2ms
memory: 8344kb

input:

2000 0
836 681 896 743 896 179 455 358 975 7 681 109 434 847 226 878 352 835 665 569 694 543 35 103 719 764 921 671 739 70 972 467 1001 835 613 209 593 617 940 69 170 622 651 981 309 191 492 513 811 909 74 527 511 222 565 304 415 17 695 332 474 237 519 568 118 86 22 185 174 690 977 404 502 600 965 6...

output:

889

result:

ok "889"

Subtask #3:

score: 0
Runtime Error

Test #31:

score: 0
Runtime Error

input:

200000 0
1 2 2 2 2 2 2 1 1 2 2 1 1 1 2 1 1 1 2 1 2 1 1 1 2 1 1 1 1 2 2 2 2 2 1 2 2 1 2 1 1 2 2 2 2 1 2 2 1 2 1 1 2 1 1 2 1 2 2 1 2 2 2 1 1 2 1 1 1 2 2 2 2 1 1 2 2 1 1 2 1 2 2 2 2 2 1 1 2 2 2 2 1 2 1 2 2 2 1 2 2 2 2 1 2 2 2 1 1 1 2 2 1 2 2 2 1 1 1 1 1 2 1 2 1 2 1 2 1 2 1 2 2 1 2 2 2 1 1 1 2 1 2 1 1 1...

output:


result:


Subtask #4:

score: 0
Runtime Error

Test #61:

score: 0
Runtime Error

input:

200000 200000
1 2 1 2 2 1 2 1 2 1 1 2 1 1 2 1 1 2 1 2 2 1 2 2 2 1 2 2 2 2 2 1 2 1 2 1 1 2 1 1 2 2 2 1 1 2 2 1 2 1 2 1 1 2 1 2 2 2 1 2 1 2 1 1 1 1 2 1 1 1 1 1 1 1 2 2 2 2 2 2 2 1 1 2 2 1 2 2 2 2 2 1 1 1 2 2 2 1 1 1 1 1 1 1 2 2 1 2 2 1 1 1 1 1 2 2 2 2 2 2 1 1 2 2 2 1 2 2 2 2 1 1 1 2 2 1 2 2 2 1 1 1 2 ...

output:


result:


Subtask #5:

score: 20
Accepted

Test #71:

score: 20
Accepted
time: 1275ms
memory: 16772kb

input:

100000 100000
2 1 1 1 1 1 1 2 2 2 2 1 2 1 1 1 2 2 1 2 1 2 2 2 2 2 2 2 1 2 2 2 1 1 1 1 1 2 2 2 2 1 1 2 2 2 1 2 2 1 2 1 2 2 2 2 1 2 1 1 1 2 2 2 1 1 2 1 1 1 2 1 2 2 2 1 1 2 1 1 2 1 1 1 1 1 1 1 2 2 1 1 2 1 2 1 2 1 2 2 2 2 2 2 2 1 1 1 1 2 1 2 1 1 1 1 2 2 2 1 2 1 1 1 2 2 2 1 1 2 1 2 2 2 2 2 1 1 2 1 1 1 1 ...

output:

49860
49859
49859
49859
49858
49858
49858
49859
49858
49858
49857
49858
49858
49857
49856
49855
49854
49854
49854
49854
49854
49854
49854
49854
49853
49853
49854
49854
49855
49855
49854
49854
49853
49852
49852
49852
49852
49851
49851
49852
49852
49851
49850
49849
49849
49849
49849
49848
49848
49848
...

result:

ok 100001 tokens

Test #72:

score: 20
Accepted
time: 1288ms
memory: 16660kb

input:

100000 100000
2 2 1 1 1 2 2 2 1 2 1 2 2 2 2 1 2 2 1 2 2 2 1 1 1 1 2 2 1 2 1 1 2 1 2 1 2 2 1 2 1 2 1 1 2 2 2 1 2 1 1 1 1 1 2 1 2 2 1 1 1 1 2 2 2 2 1 2 2 1 1 2 2 1 2 2 2 1 1 1 2 2 2 2 1 2 2 1 2 2 1 1 1 2 1 1 2 1 2 2 2 1 1 1 2 1 1 2 2 1 1 1 1 2 2 1 2 1 1 1 2 2 1 1 1 2 2 1 1 1 2 2 2 1 2 1 2 2 2 2 1 2 1 ...

output:

49869
49870
49871
49871
49872
49872
49871
49872
49872
49871
49871
49870
49870
49871
49871
49870
49869
49870
49870
49870
49871
49871
49871
49872
49873
49872
49873
49873
49873
49873
49873
49874
49874
49874
49874
49875
49874
49875
49876
49875
49876
49876
49876
49876
49876
49876
49876
49876
49875
49874
...

result:

ok 100001 tokens

Test #73:

score: 20
Accepted
time: 1348ms
memory: 21228kb

input:

100000 100000
1 4 3 1 1 3 2 1 3 1 3 4 3 4 1 1 3 2 4 3 4 4 1 3 3 1 1 4 1 1 3 4 2 1 2 1 4 4 3 3 2 3 1 3 3 1 4 4 3 2 4 4 4 1 1 4 1 4 3 1 2 4 2 2 4 2 4 3 3 4 1 4 3 1 4 4 3 2 3 4 4 4 3 4 2 4 3 4 4 2 3 1 3 3 1 3 1 4 3 3 2 3 1 3 2 3 2 3 1 4 2 3 4 2 1 3 1 4 1 1 3 2 1 4 3 1 4 4 2 4 2 2 2 1 1 4 3 3 1 3 2 4 4 ...

output:

49452
49452
49452
49451
49451
49452
49451
49451
49451
49450
49450
49451
49450
49449
49449
49449
49450
49449
49448
49448
49447
49446
49446
49446
49447
49447
49448
49448
49448
49448
49448
49449
49449
49450
49451
49451
49451
49451
49451
49451
49451
49452
49453
49454
49455
49456
49456
49456
49455
49455
...

result:

ok 100001 tokens

Test #74:

score: 20
Accepted
time: 1296ms
memory: 18532kb

input:

100000 100000
3 4 3 1 3 3 2 4 1 4 3 2 1 3 2 4 2 4 1 1 4 2 2 2 2 4 2 1 1 2 3 1 1 1 2 4 4 3 1 4 1 4 2 4 4 4 2 3 1 4 3 1 1 2 1 4 2 2 3 4 4 2 1 1 3 1 2 1 2 3 1 3 1 4 2 3 2 1 1 1 1 2 3 3 1 3 1 1 1 2 3 4 1 2 2 1 3 1 1 3 2 1 1 4 4 1 4 1 3 1 1 4 1 3 3 4 3 3 4 1 3 1 1 3 4 1 3 2 4 3 4 2 3 3 2 1 2 1 3 4 1 1 2 ...

output:

49676
49675
49675
49675
49675
49676
49676
49677
49677
49677
49676
49677
49678
49678
49678
49677
49677
49677
49677
49677
49678
49679
49679
49679
49679
49680
49680
49680
49680
49680
49680
49680
49681
49682
49683
49683
49684
49685
49685
49684
49683
49683
49684
49684
49684
49684
49685
49685
49686
49686
...

result:

ok 100001 tokens

Test #75:

score: 20
Accepted
time: 1325ms
memory: 23528kb

input:

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

output:

49692
49691
49691
49690
49690
49690
49690
49690
49690
49689
49690
49690
49690
49690
49691
49691
49691
49690
49690
49689
49688
49688
49688
49687
49686
49685
49684
49684
49683
49682
49683
49682
49682
49682
49682
49681
49680
49681
49681
49682
49682
49682
49682
49682
49682
49682
49683
49684
49685
49685
...

result:

ok 100001 tokens

Test #76:

score: 20
Accepted
time: 1317ms
memory: 23040kb

input:

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

output:

49666
49666
49667
49666
49667
49668
49667
49666
49667
49667
49668
49668
49668
49668
49668
49669
49668
49668
49667
49668
49667
49668
49668
49668
49668
49667
49668
49669
49670
49671
49671
49671
49671
49671
49672
49673
49673
49673
49673
49672
49672
49672
49671
49671
49672
49672
49672
49671
49671
49672
...

result:

ok 100001 tokens

Test #77:

score: 20
Accepted
time: 1316ms
memory: 26112kb

input:

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

output:

49442
49442
49441
49440
49441
49441
49440
49439
49440
49440
49439
49438
49438
49437
49436
49436
49436
49436
49435
49434
49434
49434
49434
49433
49434
49435
49434
49434
49434
49434
49433
49433
49433
49433
49432
49432
49432
49432
49432
49432
49433
49432
49432
49432
49432
49432
49433
49432
49432
49433
...

result:

ok 100001 tokens

Test #78:

score: 20
Accepted
time: 1350ms
memory: 27260kb

input:

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

output:

49476
49477
49478
49477
49478
49478
49479
49480
49479
49479
49479
49479
49479
49480
49480
49479
49480
49479
49480
49481
49482
49482
49481
49480
49480
49479
49479
49479
49479
49478
49478
49479
49479
49479
49479
49479
49478
49479
49479
49479
49479
49479
49479
49480
49481
49481
49481
49481
49481
49480
...

result:

ok 100001 tokens

Test #79:

score: 20
Accepted
time: 1357ms
memory: 31352kb

input:

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

output:

49517
49516
49516
49516
49516
49516
49516
49516
49517
49518
49518
49518
49519
49520
49521
49522
49522
49523
49523
49523
49524
49524
49523
49523
49523
49523
49522
49523
49523
49522
49522
49521
49522
49522
49522
49521
49521
49521
49520
49520
49520
49520
49520
49520
49520
49520
49520
49521
49521
49522
...

result:

ok 100001 tokens

Test #80:

score: 20
Accepted
time: 1286ms
memory: 29704kb

input:

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

output:

49276
49276
49275
49275
49275
49276
49277
49277
49277
49278
49277
49277
49278
49278
49279
49278
49277
49276
49277
49278
49279
49280
49280
49281
49280
49280
49279
49279
49278
49279
49279
49279
49278
49279
49280
49279
49280
49280
49280
49279
49280
49281
49280
49280
49280
49281
49280
49281
49280
49280
...

result:

ok 100001 tokens

Test #81:

score: 20
Accepted
time: 1257ms
memory: 34940kb

input:

100000 100000
19 34 10 55 34 8 41 25 38 1 64 28 56 39 61 44 12 42 53 47 33 58 9 21 52 7 49 19 29 57 53 39 15 8 46 60 61 30 56 6 54 53 25 58 51 28 10 14 53 13 16 16 18 36 37 54 21 13 29 57 36 2 1 5 18 46 1 59 28 47 37 27 31 26 15 50 30 60 19 4 2 18 44 46 45 34 17 6 39 14 7 33 40 62 59 18 17 36 15 11 ...

output:

49064
49063
49062
49062
49062
49061
49061
49060
49060
49060
49060
49060
49060
49060
49059
49059
49059
49059
49060
49059
49060
49061
49060
49061
49061
49061
49062
49062
49063
49062
49062
49063
49062
49062
49061
49062
49061
49061
49061
49062
49062
49063
49063
49062
49062
49063
49062
49062
49063
49064
...

result:

ok 100001 tokens

Test #82:

score: 20
Accepted
time: 1284ms
memory: 33552kb

input:

100000 100000
20 56 8 35 5 20 5 33 6 46 52 6 10 15 19 40 38 23 40 50 26 27 25 34 45 46 58 51 18 29 44 16 7 39 32 30 28 55 34 11 36 46 39 11 10 15 55 8 25 57 60 11 4 35 12 31 31 64 40 9 24 48 39 23 11 52 44 2 45 27 13 2 9 33 30 28 61 18 6 35 46 6 29 42 34 42 51 58 39 14 16 56 46 11 17 49 47 11 6 25 4...

output:

49123
49122
49122
49122
49122
49123
49124
49125
49125
49124
49124
49124
49124
49125
49125
49124
49124
49123
49124
49124
49123
49123
49123
49122
49122
49123
49124
49123
49124
49123
49122
49122
49121
49122
49121
49120
49120
49120
49120
49120
49119
49120
49120
49120
49119
49119
49118
49118
49118
49118
...

result:

ok 100001 tokens

Test #83:

score: 20
Accepted
time: 1233ms
memory: 38596kb

input:

100000 100000
48 13 113 16 50 126 25 5 16 41 9 85 68 76 39 114 44 52 88 21 39 60 124 96 33 96 53 7 54 38 117 43 71 9 89 94 94 63 13 121 107 10 49 22 65 15 125 13 31 60 100 113 61 88 51 30 108 90 20 21 75 10 107 91 74 12 75 116 52 69 15 103 62 122 23 61 12 36 88 96 5 69 95 35 124 48 80 65 68 70 103 1...

output:

48724
48724
48724
48724
48724
48724
48725
48725
48725
48726
48727
48728
48728
48727
48728
48729
48728
48729
48728
48729
48728
48728
48729
48728
48727
48728
48728
48727
48727
48727
48727
48726
48725
48725
48725
48726
48727
48728
48728
48728
48729
48728
48729
48728
48728
48728
48727
48727
48728
48729
...

result:

ok 100001 tokens

Test #84:

score: 20
Accepted
time: 1245ms
memory: 37292kb

input:

100000 100000
100 113 33 10 61 96 68 19 114 4 75 63 90 31 40 49 6 42 98 50 83 107 16 123 80 70 73 37 69 22 24 5 75 55 21 22 96 76 100 126 119 18 76 123 67 63 50 13 74 31 116 89 104 73 100 31 49 82 8 114 26 25 79 59 19 90 115 15 12 18 52 19 61 25 55 49 67 65 109 70 72 45 76 123 32 59 75 93 117 49 107...

output:

48763
48764
48764
48763
48763
48764
48764
48764
48764
48764
48765
48764
48764
48764
48764
48765
48765
48765
48764
48763
48764
48765
48764
48763
48762
48762
48762
48763
48764
48763
48762
48762
48762
48763
48763
48763
48763
48763
48763
48762
48762
48763
48763
48763
48763
48762
48761
48761
48760
48761
...

result:

ok 100001 tokens

Test #85:

score: 20
Accepted
time: 1199ms
memory: 39724kb

input:

100000 100000
175 25 142 240 193 61 252 60 221 64 125 143 41 142 64 77 196 178 42 250 13 125 25 182 61 107 212 75 146 39 234 210 151 79 219 5 160 51 34 196 86 124 107 10 238 8 247 127 109 6 114 29 251 159 202 11 225 69 7 145 256 175 126 49 195 42 178 117 48 108 119 79 154 137 25 95 91 165 73 227 122...

output:

48301
48301
48302
48302
48302
48303
48303
48304
48303
48303
48303
48303
48302
48303
48303
48303
48302
48302
48301
48301
48301
48300
48300
48301
48301
48301
48300
48300
48300
48300
48300
48301
48300
48300
48300
48301
48301
48301
48300
48300
48299
48299
48300
48300
48301
48302
48301
48301
48301
48302
...

result:

ok 100001 tokens

Test #86:

score: 20
Accepted
time: 1182ms
memory: 42716kb

input:

100000 100000
107 75 230 30 149 43 171 147 169 235 147 168 132 231 125 12 12 23 32 252 143 161 133 68 123 154 111 117 164 89 48 164 109 44 151 179 26 9 230 92 114 83 199 137 27 26 106 52 192 120 17 159 13 12 225 26 117 225 96 180 125 66 83 97 169 84 222 208 147 7 28 228 247 190 17 156 41 26 116 6 20...

output:

48305
48306
48307
48308
48308
48307
48306
48306
48306
48306
48305
48305
48305
48305
48306
48306
48306
48307
48307
48306
48306
48306
48306
48306
48305
48305
48305
48304
48304
48305
48305
48304
48304
48304
48303
48303
48304
48304
48304
48305
48305
48304
48304
48304
48303
48303
48304
48305
48306
48306
...

result:

ok 100001 tokens

Test #87:

score: 20
Accepted
time: 1080ms
memory: 46308kb

input:

100000 100000
158 184 26 364 149 502 96 204 25 81 177 112 273 447 69 92 287 34 439 132 32 261 319 258 158 345 492 418 293 103 415 231 12 150 407 490 86 411 407 48 216 423 203 86 105 128 502 432 486 491 258 393 304 279 56 286 239 375 280 403 442 225 418 33 191 169 227 342 397 201 216 127 193 217 281 ...

output:

47479
47479
47479
47479
47478
47479
47479
47479
47479
47480
47480
47480
47480
47480
47480
47479
47479
47478
47479
47479
47479
47479
47479
47479
47479
47480
47480
47479
47479
47478
47478
47478
47477
47477
47476
47476
47476
47476
47476
47476
47476
47476
47476
47476
47476
47477
47476
47476
47477
47476
...

result:

ok 100001 tokens

Test #88:

score: 20
Accepted
time: 1077ms
memory: 45080kb

input:

100000 100000
162 2 113 232 80 339 53 323 211 251 276 371 314 26 280 510 253 264 442 371 205 289 218 216 28 434 495 156 213 493 231 455 254 336 436 160 419 55 451 311 140 288 48 280 257 186 48 427 5 67 425 301 299 128 480 245 66 480 511 336 105 44 5 222 241 343 303 143 37 491 152 198 334 104 76 434 ...

output:

47782
47782
47782
47783
47782
47782
47783
47783
47782
47783
47784
47785
47784
47784
47783
47783
47783
47784
47784
47783
47783
47783
47783
47783
47782
47782
47782
47781
47781
47781
47781
47781
47781
47780
47780
47780
47780
47779
47779
47778
47777
47777
47777
47777
47777
47777
47776
47776
47777
47777
...

result:

ok 100001 tokens

Test #89:

score: 20
Accepted
time: 1023ms
memory: 48860kb

input:

100000 100000
394 530 447 794 760 152 774 216 616 750 397 648 672 17 773 303 414 89 524 484 661 523 693 965 927 995 1007 656 901 358 252 412 949 1012 61 548 64 392 784 538 626 479 955 258 993 852 255 689 884 415 418 691 165 34 335 338 474 680 530 964 538 874 119 988 230 87 926 52 847 912 297 131 278...

output:

47211
47212
47213
47213
47213
47214
47214
47215
47215
47215
47215
47214
47214
47215
47214
47215
47214
47215
47215
47215
47215
47215
47215
47215
47215
47215
47215
47215
47216
47215
47214
47214
47215
47214
47213
47214
47213
47213
47212
47211
47210
47210
47211
47210
47211
47212
47212
47211
47210
47210
...

result:

ok 100001 tokens

Test #90:

score: 20
Accepted
time: 1067ms
memory: 51952kb

input:

100000 100000
569 255 794 198 622 989 820 175 732 390 617 484 977 607 165 453 133 290 432 360 947 324 121 367 602 266 101 793 427 460 532 697 215 533 731 207 248 97 11 637 885 791 919 91 445 657 748 1015 419 846 11 22 133 276 581 968 52 687 192 10 977 84 900 655 826 304 527 554 314 725 786 173 679 2...

output:

47148
47148
47148
47147
47146
47146
47146
47145
47145
47145
47144
47144
47143
47142
47142
47142
47141
47140
47139
47138
47139
47139
47140
47141
47142
47143
47144
47144
47144
47144
47144
47145
47145
47145
47145
47145
47145
47146
47146
47146
47146
47147
47146
47145
47145
47145
47145
47145
47145
47146
...

result:

ok 100001 tokens

Test #91:

score: 20
Accepted
time: 1016ms
memory: 54052kb

input:

100000 100000
1714 990 329 1800 1539 1676 318 1021 425 1292 1212 1146 238 1420 1335 1335 570 157 1025 62 1289 862 548 640 1741 1423 927 1109 1897 409 73 67 191 1880 1182 1434 963 1662 29 10 858 101 1635 626 589 248 1557 1564 1706 1429 1208 246 924 218 261 1249 816 25 724 1611 3 1433 807 1162 544 984...

output:

45929
45930
45930
45930
45930
45930
45930
45929
45929
45929
45928
45927
45928
45928
45928
45927
45926
45926
45926
45925
45924
45925
45925
45926
45927
45927
45926
45927
45928
45929
45929
45928
45927
45927
45926
45926
45926
45926
45927
45928
45928
45928
45929
45928
45928
45928
45929
45930
45931
45932
...

result:

ok 100001 tokens

Test #92:

score: 20
Accepted
time: 1007ms
memory: 52692kb

input:

100000 100000
42 742 213 2039 1816 921 1040 816 667 940 299 1847 388 523 109 1849 588 967 474 676 1027 1306 1873 356 781 975 1655 671 511 1412 759 1872 990 1892 896 96 603 831 397 1282 235 470 365 277 457 566 368 1681 1282 793 1082 339 785 762 1243 1837 1095 110 1210 212 1167 857 1245 202 770 1406 1...

output:

46025
46025
46024
46024
46024
46023
46023
46024
46024
46025
46025
46025
46026
46025
46026
46026
46027
46026
46026
46027
46028
46029
46030
46030
46031
46030
46030
46031
46032
46032
46032
46031
46031
46032
46032
46033
46033
46032
46033
46033
46033
46033
46032
46032
46031
46032
46033
46032
46031
46030
...

result:

ok 100001 tokens

Test #93:

score: 20
Accepted
time: 945ms
memory: 57956kb

input:

100000 100000
3459 1322 3376 1761 1317 416 92 2336 2759 766 182 3929 3010 263 465 1994 1872 3928 15 762 3777 2430 3937 2504 790 2821 1113 3391 2959 3903 2100 3084 435 1214 447 2911 697 797 2647 630 2376 2699 3453 751 1625 3794 2601 3536 471 1775 1466 2257 1614 2090 3456 1393 2390 3158 734 441 1292 3...

output:

45274
45274
45274
45273
45273
45274
45274
45274
45274
45274
45275
45275
45276
45276
45275
45275
45275
45276
45276
45276
45276
45276
45276
45276
45276
45277
45278
45279
45278
45278
45279
45279
45279
45278
45278
45279
45279
45279
45279
45278
45278
45277
45276
45277
45278
45279
45279
45278
45277
45276
...

result:

ok 100001 tokens

Test #94:

score: 20
Accepted
time: 919ms
memory: 58016kb

input:

100000 100000
1273 2756 2907 3489 1762 1707 820 1350 3912 3398 868 1867 3555 3275 134 1168 2880 1205 3581 1520 2922 3869 2553 462 555 4018 2212 925 257 1140 1290 991 2559 2620 2794 3570 2131 3624 2061 2433 781 981 236 2596 618 3853 3646 2127 1122 1180 528 2026 497 3187 3642 1120 1901 2307 1814 1012 ...

output:

45126
45125
45125
45126
45126
45125
45125
45125
45125
45124
45124
45124
45123
45123
45122
45122
45122
45122
45122
45122
45122
45123
45123
45122
45122
45122
45121
45120
45119
45119
45119
45119
45118
45118
45118
45119
45119
45119
45118
45117
45117
45117
45116
45116
45115
45116
45117
45117
45116
45116
...

result:

ok 100001 tokens

Test #95:

score: 20
Accepted
time: 825ms
memory: 62104kb

input:

100000 100000
918 1374 2569 1511 7013 2288 7022 2226 6822 1197 5432 3986 8161 846 3311 8033 8121 7388 2061 3868 6971 3114 5150 7868 7460 3131 6754 1314 5445 6135 7111 6949 4806 6477 976 5459 1947 2414 6682 1986 7925 2606 3118 3458 4912 113 7865 429 511 5190 2905 3823 7938 7421 5208 6241 2002 1935 75...

output:

44272
44273
44272
44273
44273
44273
44272
44272
44272
44273
44273
44274
44274
44275
44275
44275
44275
44276
44276
44275
44275
44275
44275
44274
44274
44274
44275
44275
44276
44275
44275
44275
44275
44275
44276
44276
44276
44276
44276
44276
44275
44274
44274
44273
44274
44275
44276
44275
44275
44275
...

result:

ok 100001 tokens

Test #96:

score: 20
Accepted
time: 814ms
memory: 61808kb

input:

100000 100000
1556 3900 1939 2875 5195 2979 3826 3024 124 5230 534 8182 4618 7309 6899 2408 5660 6971 3185 5427 4699 3682 6177 4882 3546 2599 3267 2826 1559 2712 3530 612 6601 6394 7331 3707 4500 598 7578 6604 35 2588 1726 1862 5040 6871 677 3975 482 3292 6253 8069 224 4171 3966 6734 4697 217 4044 8...

output:

44290
44291
44292
44293
44293
44293
44294
44294
44294
44295
44294
44294
44294
44293
44293
44294
44295
44294
44295
44296
44297
44297
44297
44296
44297
44297
44298
44299
44299
44300
44300
44300
44301
44301
44301
44301
44301
44302
44301
44302
44302
44301
44301
44300
44300
44300
44300
44300
44300
44300
...

result:

ok 100001 tokens

Test #97:

score: 20
Accepted
time: 679ms
memory: 64520kb

input:

100000 100000
1038 4530 2112 9479 3907 2419 9927 2503 6132 7792 432 14664 14841 11977 3043 15054 9166 3764 274 6283 1776 13289 51 6986 12078 13989 4648 3951 3957 9978 7049 6624 1352 7544 6657 11628 10189 1022 9907 5160 7886 15175 5107 2858 11839 5411 2016 4759 921 1778 14214 13833 8879 8101 10692 61...

output:

43456
43456
43456
43456
43456
43457
43458
43458
43459
43458
43457
43456
43456
43457
43457
43457
43457
43456
43456
43456
43456
43456
43457
43456
43456
43456
43456
43456
43457
43456
43456
43455
43455
43455
43454
43454
43454
43454
43453
43453
43453
43453
43452
43453
43453
43453
43453
43452
43452
43452
...

result:

ok 100001 tokens

Test #98:

score: 20
Accepted
time: 657ms
memory: 64292kb

input:

100000 100000
9331 1848 15611 14825 12931 9775 6841 1224 10627 5383 246 15594 10189 629 12013 7534 9507 10595 12245 1957 14491 5932 5538 5739 15059 10900 1072 15523 9446 10028 10328 14341 11195 13135 14882 113 9872 14258 6382 5559 15459 15192 8323 8225 10696 12368 6940 233 13678 3387 3514 4594 622 1...

output:

43491
43491
43491
43490
43491
43492
43491
43490
43489
43489
43489
43489
43489
43490
43490
43489
43489
43490
43490
43489
43489
43489
43489
43488
43488
43489
43489
43489
43488
43487
43487
43487
43486
43486
43487
43488
43488
43487
43488
43488
43488
43489
43490
43490
43490
43490
43491
43492
43492
43492
...

result:

ok 100001 tokens

Test #99:

score: 20
Accepted
time: 571ms
memory: 69572kb

input:

100000 100000
17896 4044 6759 20664 30428 25108 7597 24899 22842 20930 25158 23548 10625 4413 17599 188 19568 3602 28473 26036 470 10417 4327 4284 10463 29534 4725 8396 12390 4484 29657 6212 18345 13920 2294 23761 1756 3847 9243 29115 2255 2009 24516 21815 10784 32159 254 25713 14932 8626 4880 12416...

output:

43843
43844
43845
43844
43845
43844
43843
43843
43843
43844
43844
43844
43845
43846
43846
43846
43846
43846
43845
43845
43845
43845
43844
43843
43842
43842
43843
43843
43844
43844
43845
43846
43846
43845
43845
43845
43845
43845
43845
43846
43845
43844
43844
43843
43844
43844
43844
43844
43845
43846
...

result:

ok 100001 tokens

Test #100:

score: 20
Accepted
time: 560ms
memory: 67808kb

input:

100000 100000
31117 4043 256 21783 29960 26507 21852 27162 28851 9573 29069 19689 22079 31545 9439 1461 23038 6220 466 2411 29331 26896 5825 19812 19037 23156 21878 7393 17730 5849 1334 11379 13332 4496 17056 4109 25866 2909 13561 31909 9583 16706 19029 5467 19649 17579 11001 32700 15407 12683 14521...

output:

43712
43712
43712
43713
43712
43711
43710
43709
43709
43709
43709
43709
43709
43708
43708
43708
43707
43707
43707
43706
43707
43706
43707
43708
43709
43710
43709
43710
43710
43710
43710
43711
43711
43712
43712
43712
43713
43714
43713
43712
43712
43711
43711
43710
43711
43711
43711
43711
43710
43711
...

result:

ok 100001 tokens

Subtask #6:

score: 0
Runtime Error

Test #101:

score: 0
Runtime Error

input:

200000 200000
1 2 1 1 2 1 1 1 2 1 2 2 2 1 2 1 1 2 2 2 1 2 2 2 2 1 2 1 1 1 1 2 1 2 2 1 2 2 2 2 1 1 1 2 1 1 1 2 2 1 1 1 2 1 1 2 1 1 2 2 1 1 2 2 2 1 1 1 1 1 1 2 1 1 2 1 2 2 1 2 2 2 1 2 2 1 2 2 1 1 1 1 1 2 2 2 1 1 2 2 1 1 1 2 2 1 1 2 2 2 2 2 2 1 2 1 1 2 2 2 1 1 1 2 1 2 1 1 1 1 1 2 1 1 2 2 1 1 2 2 1 2 1 ...

output:


result: