QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#334490#6313. 人员调度luyiming12356 4989ms155784kbC++237.4kb2024-02-22 00:52:302024-02-22 00:52:30

Judging History

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

  • [2024-02-22 00:52:30]
  • 评测
  • 测评结果:56
  • 用时:4989ms
  • 内存:155784kb
  • [2024-02-22 00:52:30]
  • 提交

answer

# include <bits/stdc++.h>
# define pii pair <int, int> 
# define mp make_pair 
using namespace std; 
using i64 = long long;
const int N = 2e5 + 5; 
int n, k; 
vector <int> g[N]; 

int dfn[N], fid[N], dep[N], siz[N], son[N], dfntot = 0, fa[N], top[N]; 
void dfs1(int x, int fa)
{
    ::fa[x] = fa; dep[x] = dep[fa] + 1, siz[x] = 1; 
    for(int v : g[x])
    {
        if(v == fa) continue; 
        dfs1(v, x); siz[x] += siz[v]; 
        if(!son[x] || siz[v] > siz[son[x]]) son[x] = v; 
    }
    return; 
}

void dfs2(int x, int _t)
{
    top[x] = _t; dfn[x] = ++dfntot, fid[dfn[x]] = x; 
    if(son[x]) dfs2(son[x], _t); 
    for(int v : g[x])
    {
        if(v == fa[x] || v == son[x]) continue; 
        dfs2(v, v); 
    }
    return; 
}

struct SgT
{
    struct node
    {
        int Minw, tagw; set <pii> S; i64 sum; 
    }T[N << 2]; 

    void pushup(int root) 
    {
        T[root].Minw = min(T[root << 1].Minw, T[root << 1 | 1].Minw); 
        // T[root].sum = T[root << 1].sum + T[root << 1 | 1].sum; 
        return; 
    }

    void pushtag(int root, int d)
    {
        T[root].Minw += d; T[root].tagw += d; return; 
    }

    void pushdown(int root)
    {
        if(!T[root].tagw) return; 
        pushtag(root << 1, T[root].tagw), pushtag(root << 1 | 1, T[root].tagw); 
        T[root].tagw = 0; 
        return; 
    }

    void build(int root, int l, int r)
    {
        if(l == r)
        {
            T[root].Minw = siz[fid[l]], T[root].tagw = T[root].sum = 0; 
            return; 
        }
        int mid = (l + r) >> 1; 
        build(root << 1, l, mid), build(root << 1 | 1, mid + 1, r); 
        pushup(root); 
        return; 
    }

    void insordel(int root, int l, int r, int x, int v, bool del = 0)
    {
        if(del) T[root].S.erase({v, fid[x]}), T[root].sum -= v; 
        else T[root].S.insert({v, fid[x]}), T[root].sum += v; 
        if(l == r) return; 
        pushdown(root); 
        int mid = (l + r) >> 1; 
        if(x <= mid) insordel(root << 1, l, mid, x, v, del); 
        else insordel(root << 1 | 1, mid + 1, r, x, v, del); 
        pushup(root); 
        return; 
    }

    void update_add(int root, int l, int r, int s, int t, int d)
    {
        // fprintf(stderr, "root = %d, l = %d, r = %d, s = %d, t = %d, d = %d\n", root, l, r, s, t, d); 
        if(l <= s && t <= r) 
        {
            pushtag(root, d); return; 
        }
        pushdown(root); 
        int mid = (s + t) >> 1; 
        if(l <= mid) update_add(root << 1, l, r, s, mid, d); 
        if(r > mid) update_add(root << 1 | 1, l, r, mid + 1, t, d); 
        pushup(root); 
        return; 
    }

    pii query(int root, int l, int r, int s, int t)
    {
        if(l <= s && t <= r) 
        {
            if(T[root].S.empty()) return mp(2e9, 0); 
            else return (*T[root].S.begin()); 
        }
        pushdown(root); 
        int mid = (s + t) >> 1; pii ans = mp(2e9, 0);  
        if(l <= mid) ans = min(ans, query(root << 1, l, r, s, mid)); 
        if(r > mid) ans = min(ans, query(root << 1 | 1, l, r, mid + 1, t)); 
        return ans; 
    }

    int query_Minw(int root, int l, int r, int s, int t)
    {
        if(T[root].Minw > 0) return -1; 
        if(s == t) return fid[s]; 
        pushdown(root); 
        int mid = (s + t) >> 1; 
        if(r <= mid) return query_Minw(root << 1, l, r, s, mid); 
        else if(l > mid) return query_Minw(root << 1 | 1, l, r, mid + 1, t); 
        else 
        {
            int lst = query_Minw(root << 1 | 1, l, r, mid + 1, t); 
            if(lst == -1) return query_Minw(root << 1, l, r, s, mid); 
            else return lst; 
        }
    }

}Tr; 

vector <pii> Seg[N << 2]; 

void Ins(int root, int l, int r, int s, int t, int x, int v)
{
    if(l <= s && t <= r) {Seg[root].emplace_back(x, v); return; }
    int mid = (s + t) >> 1; 
    if(l <= mid) Ins(root << 1, l, r, s, mid, x, v); 
    if(r > mid) Ins(root << 1 | 1, l, r, mid + 1, t, x, v); 
    return; 
}

struct Option
{
    int opt, x, d; 
    // opt = 1 表示 点x(不是 dfn) 删除 
    // opt = 2                    加入
}; 

void Upd(int x, int y, int d) // 给 path(x, y) 上的 w 加 d
{
    while(top[x] != top[y]) 
    { 
        if(dep[x] > dep[y]) swap(x, y);
        Tr.update_add(1, dfn[top[y]], dfn[y], 1, n, d); 
        y = fa[top[y]]; 
    }
    if(dfn[x] > dfn[y]) swap(x, y); 
    Tr.update_add(1, dfn[x], dfn[y], 1, n, d); 
    return; 
}

void Inspt(int x, int v, vector <Option> &Os)
{
    // find y
    int y = x; 
    while(y)
    {
        int idx = Tr.query_Minw(1, dfn[top[y]], dfn[y], 1, n); 
        if(idx != -1) {y = idx; break; }
        else y = fa[top[y]]; 
    }
    // printf("y = %d\n", y); 
    if(!y) 
    {
        Tr.insordel(1, 1, n, dfn[x], v); Upd(1, x, -1); 
        Os.push_back({2, x, v}); 
        return; 
    }
    else
    {
        auto [val, idx] = Tr.query(1, dfn[y], dfn[y] + siz[y] - 1, 1, n); 
        // printf("val = %d, idx = %d\n", val, idx); 
        assert(val < 1e9);
        if(v <= val) return; 
        else 
        {
            Tr.insordel(1, 1, n, dfn[idx], val, 1); Upd(1, idx, 1); 
            Os.push_back({1, idx, val});
            Tr.insordel(1, 1, n, dfn[x], v); Upd(1, x, -1); 
            Os.push_back({2, x, v});  
        }
    }
    return; 
}
i64 Ans[N];
void Solve(int root, int l, int r)
{
    // printf("Solve : root = %d, l = %d, r = %d\nS : ", root, l, r); 
    // for(auto [v, x] : Tr.T[1].S) printf("%d %d\n", x, v); 
    vector <Option> Os; 
    for(auto [x, v] : Seg[root])
    {
        // printf("Inspt : (%d, %d)\n", x, v); 
        Inspt(x, v, Os); 
    }
    if(l == r)
    {
        // printf("l = %d\nS : ", l); 
        
        Ans[l] = Tr.T[1].sum;
    }
    else 
    {
        int mid = (l + r) >> 1; 
        Solve(root << 1, l, mid), Solve(root << 1 | 1, mid + 1, r); 
    }
    // printf("Start Back\n"); 
    for(int i = (int)Os.size() - 1; i >= 0; i--) 
    {
        auto [opt, x, d] = Os[i]; 
        if(opt == 1) Tr.insordel(1, 1, n, dfn[x], d), Upd(1, x, -1); //, printf("Backadd : (%d, %d)\n", x, d); 
        else Tr.insordel(1, 1, n, dfn[x], d, 1), Upd(1, x, 1); //, printf("Backdel : (%d, %d)\n", x, d); 
    }
    Os.clear(); Os.shrink_to_fit(); 
    return; 
}

pii Pts[N]; int lf[N], rg[N]; 

signed main(void)
{
    scanf("%d", &n); int Test; 
    scanf("%d%d%d", &n, &k, &Test); 
    for(int i = 2; i <= n; i++) 
    {
        int f; scanf("%d", &f); g[f].emplace_back(i); 
    }
    dfs1(1, 0), dfs2(1, 1); Tr.build(1, 1, n); 
    // for(int i = 1; i <= n; i++) printf("dfn[%d] = %d, siz[%d] = %d, dep[%d] = %d\n", i, dfn[i], i, siz[i], i, dep[i]); 
    for(int i = 1; i <= k; i++)
    {
        int x, v; scanf("%d%d", &x, &v); Pts[i] = {x, v}; lf[i] = 0, rg[i] = Test; 
    }
    for(int i = 1; i <= Test; i++)
    {
        int opt; scanf("%d", &opt); 
        if(opt == 1)
        {
            int x, v; scanf("%d%d", &x, &v); Pts[++k] = {x, v}; lf[k] = i, rg[k] = Test; 
        }
        else 
        {
            int x; scanf("%d", &x); rg[x] = i - 1; 
        }
    }
    for(int i = 1; i <= k; i++) 
    {
        assert(lf[i] <= rg[i]); 
        Ins(1, lf[i], rg[i], 0, Test, Pts[i].first, Pts[i].second);
    }
    Solve(1, 0, Test); 
    for(int i = 0; i <= Test; i++) printf("%lld ", Ans[i]); 
    return 0; 
}

详细

Test #1:

score: 2
Accepted
time: 3ms
memory: 53880kb

input:

1
6 6 6
1 2 3 2 3
1 52078
2 3759
1 85897
6 14295
3 47290
3 93702
1 2 41269
1 5 79793
1 6 88324
1 1 88307
1 4 64229
1 3 18664

output:

297021 334531 400029 447084 488101 500252 500252 

result:

ok 7 numbers

Test #2:

score: 2
Accepted
time: 11ms
memory: 54136kb

input:

2
9 6 6
1 1 2 1 5 4 5 2
2 28610
4 62909
9 44990
8 38352
8 97403
4 91172
1 7 77724
1 5 73030
1 1 74599
1 2 11376
1 9 41281
1 5 52692

output:

325084 339899 412929 487528 487528 487528 540220 

result:

ok 7 numbers

Test #3:

score: 2
Accepted
time: 3ms
memory: 53864kb

input:

2
9 6 6
1 2 3 4 4 1 3 2
2 43265
6 10749
4 75789
5 17017
3 68560
5 61211
1 1 82982
2 5
2 1
2 7
1 7 30320
2 6

output:

259574 342556 273996 230731 147749 178069 133875 

result:

ok 7 numbers

Test #4:

score: 2
Accepted
time: 4ms
memory: 53952kb

input:

3
16 66 66
1 1 2 3 4 6 6 6 5 5 5 1 1 9 10
6 17077
6 78264
13 58368
15 52835
7 36607
9 43555
5 89936
15 55777
13 44137
1 66172
8 89009
2 1318
2 63845
8 93573
13 11924
15 74580
14 20835
6 9184
14 75018
16 94155
10 48597
5 41484
4 87492
14 9932
16 21740
13 4298
7 76915
3 81689
7 3064
7 9149
1 21961
6 1...

output:

1266121 1266121 1266121 1266121 1266121 1284726 1284726 1284726 1284726 1284726 1284726 1284726 1284726 1284726 1284726 1284726 1284726 1284726 1261079 1261079 1261079 1261079 1261079 1261079 1242276 1224701 1239267 1239267 1224701 1208538 1208538 1208538 1214706 1188250 1176898 1176898 1195695 1195...

result:

ok 67 numbers

Test #5:

score: 2
Accepted
time: 4ms
memory: 54116kb

input:

3
16 66 66
1 2 3 4 5 6 7 8 8 8 8 4 4 7 8
4 17274
9 14926
1 1389
15 21673
6 63249
7 25469
7 58444
5 16209
10 14761
2 74416
10 89493
11 85483
6 60737
16 97844
15 68483
5 86467
13 46164
4 12404
11 77651
10 32071
6 61761
6 82399
2 3843
13 76772
5 60099
8 56289
10 96527
4 43558
15 48089
1 63015
7 35381
4...

output:

1405383 1410463 1410463 1410463 1410463 1410463 1406819 1393470 1393470 1393470 1393470 1393470 1393470 1393470 1377057 1377057 1377057 1399071 1399071 1399071 1399071 1399071 1399071 1399071 1399071 1377120 1377120 1377120 1377120 1401176 1401176 1379303 1379303 1379303 1379303 1379303 1359256 1349...

result:

ok 67 numbers

Test #6:

score: 2
Accepted
time: 7ms
memory: 53880kb

input:

4
66 66 0
1 2 3 1 4 5 6 8 7 10 9 12 11 14 15 13 16 18 17 19 21 20 23 24 22 26 26 26 26 26 26 26 26 26 26 26 26 26 25 25 25 25 25 25 25 25 25 25 25 25 25 28 45 17 28 3 19 19 18 46 42 35 20 7 55
39 82261
51 30803
13 11540
7 22146
43 43489
49 85871
31 55374
6 74182
50 11205
39 808
66 8446
27 38250
5 77...

output:

2611984 

result:

ok 1 number(s): "2611984"

Test #7:

score: 2
Accepted
time: 7ms
memory: 53848kb

input:

4
66 66 0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 24 7 12 3 6 19 28 45 30 18 10 50 34 58 13 63 62
64 66408
38 81306
38 76367
14 63364
13 25358
56 52456
59 22480
54 1586
32 88869
61 70293
36 63360
51 48806
...

output:

2817954 

result:

ok 1 number(s): "2817954"

Test #8:

score: 2
Accepted
time: 4ms
memory: 53888kb

input:

4
66 66 0
1 2 1 4 5 3 6 8 9 7 10 11 12 13 15 14 17 18 16 19 20 21 23 22 24 25 25 25 25 25 25 25 25 25 25 25 25 25 26 26 26 26 26 26 26 26 26 26 26 26 26 15 15 23 28 20 2 42 48 51 16 7 19 58 47
31 89942
65 66178
14 46664
27 60218
4 92822
45 64969
10 11089
56 28103
45 79709
15 21700
48 87186
1 99586
4...

output:

2963026 

result:

ok 1 number(s): "2963026"

Test #9:

score: 2
Accepted
time: 12ms
memory: 55320kb

input:

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

output:

102630666 

result:

ok 1 number(s): "102630666"

Test #10:

score: 2
Accepted
time: 16ms
memory: 55268kb

input:

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

output:

97653563 

result:

ok 1 number(s): "97653563"

Test #11:

score: 2
Accepted
time: 22ms
memory: 55460kb

input:

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

output:

96687896 

result:

ok 1 number(s): "96687896"

Test #12:

score: 2
Accepted
time: 1318ms
memory: 155720kb

input:

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

output:

5007624082 

result:

ok 1 number(s): "5007624082"

Test #13:

score: 2
Accepted
time: 1327ms
memory: 155656kb

input:

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

output:

4984117401 

result:

ok 1 number(s): "4984117401"

Test #14:

score: 2
Accepted
time: 1354ms
memory: 155784kb

input:

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

output:

4996416696 

result:

ok 1 number(s): "4996416696"

Test #15:

score: 2
Accepted
time: 1314ms
memory: 136528kb

input:

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

output:

4401773488 

result:

ok 1 number(s): "4401773488"

Test #16:

score: 2
Accepted
time: 1340ms
memory: 130680kb

input:

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

output:

4274252146 

result:

ok 1 number(s): "4274252146"

Test #17:

score: 2
Accepted
time: 1334ms
memory: 136536kb

input:

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

output:

4409489220 

result:

ok 1 number(s): "4409489220"

Test #18:

score: 2
Accepted
time: 1344ms
memory: 130792kb

input:

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

output:

4269079003 

result:

ok 1 number(s): "4269079003"

Test #19:

score: 2
Accepted
time: 49ms
memory: 55976kb

input:

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

output:

99979267 100054337 100122653 100122653 100146948 100163747 100231801 100281851 100324742 100379011 100414062 100474086 100493991 100493991 100514107 100578193 100653878 100653878 100689857 100689857 100728819 100811328 100822223 100919488 101017548 101017548 101068090 101147990 101214127 101214127 1...

result:

ok 2334 numbers

Test #20:

score: 2
Accepted
time: 52ms
memory: 56116kb

input:

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

output:

104491980 104545093 104560893 104560893 104598723 104635982 104713085 104752228 104752228 104808338 104813847 104843792 104885555 104885555 104914555 104943031 104990685 104990685 104990685 104994921 104994921 105082493 105082493 105117287 105162830 105171938 105171938 105171938 105240478 105240478 ...

result:

ok 2334 numbers

Test #21:

score: 2
Accepted
time: 53ms
memory: 56252kb

input:

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

output:

98368021 98430847 98478927 98478927 98478927 98567127 98654244 98738436 98811995 98816088 98880638 98910368 98910368 99007292 99007292 99057689 99067685 99087776 99181932 99207504 99207504 99235236 99235236 99287459 99376027 99421695 99490280 99511438 99536733 99570314 99570314 99598686 99632604 997...

result:

ok 2334 numbers

Test #22:

score: 0
Time Limit Exceeded

input:

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

output:


result:


Test #23:

score: 0
Time Limit Exceeded

input:

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

output:


result:


Test #24:

score: 0
Time Limit Exceeded

input:

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

output:


result:


Test #25:

score: 0
Time Limit Exceeded

input:

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

output:


result:


Test #26:

score: 0
Time Limit Exceeded

input:

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

output:


result:


Test #27:

score: 0
Time Limit Exceeded

input:

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

output:


result:


Test #28:

score: 0
Time Limit Exceeded

input:

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

output:


result:


Test #29:

score: 2
Accepted
time: 39ms
memory: 55912kb

input:

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

output:

98346715 98320738 98374109 98374109 98356862 98380497 98400545 98396852 98402318 98441468 98463438 98423019 98388518 98388518 98388518 98460607 98460607 98428423 98428423 98424987 98424987 98409507 98409507 98409507 98409507 98428586 98520686 98520686 98432315 98449552 98421842 98368486 98465997 983...

result:

ok 2334 numbers

Test #30:

score: 2
Accepted
time: 34ms
memory: 55744kb

input:

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

output:

99522112 99566564 99502944 99481645 99446700 99438739 99520155 99474582 99474582 99384439 99384439 99430696 99365433 99365433 99373929 99373929 99384771 99304914 99357340 99271857 99271857 99226504 99237934 99237934 99151132 99159556 99197865 99201840 99153129 99126696 99126696 99039774 99039774 990...

result:

ok 2334 numbers

Test #31:

score: 2
Accepted
time: 48ms
memory: 55904kb

input:

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

output:

98318975 98405504 98379386 98404489 98318159 98289544 98332067 98414460 98410844 98377307 98470189 98452976 98452976 98529202 98520785 98541735 98569251 98570871 98570871 98571961 98567552 98648351 98624658 98624658 98666011 98671101 98679273 98679273 98679273 98628401 98667033 98667033 98706817 986...

result:

ok 2334 numbers

Test #32:

score: 2
Accepted
time: 4159ms
memory: 137304kb

input:

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

output:

82625 82625 82624 82624 82623 82624 82624 82625 82624 82625 82625 82626 82627 82628 82628 82629 82628 82628 82627 82627 82628 82628 82629 82628 82629 82630 82629 82630 82630 82629 82630 82629 82628 82629 82628 82628 82629 82630 82630 82630 82630 82629 82628 82628 82627 82627 82628 82628 82628 82629 ...

result:

ok 100001 numbers

Test #33:

score: 2
Accepted
time: 2113ms
memory: 144800kb

input:

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

output:

82796 82796 82797 82798 82798 82799 82800 82801 82802 82803 82804 82805 82806 82807 82807 82808 82808 82808 82808 82809 82810 82810 82811 82812 82812 82812 82812 82813 82813 82814 82815 82816 82817 82817 82818 82818 82819 82820 82821 82822 82823 82824 82824 82825 82826 82826 82826 82827 82828 82829 ...

result:

ok 100001 numbers

Test #34:

score: 2
Accepted
time: 4145ms
memory: 137520kb

input:

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

output:

82783 82782 82783 82784 82783 82782 82782 82782 82781 82781 82781 82782 82782 82782 82783 82782 82781 82782 82783 82782 82781 82781 82782 82782 82781 82781 82782 82783 82782 82782 82783 82782 82783 82783 82782 82782 82783 82783 82783 82783 82782 82782 82781 82780 82779 82779 82779 82778 82777 82776 ...

result:

ok 100001 numbers

Test #35:

score: 0
Time Limit Exceeded

input:

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

output:


result:


Test #36:

score: 0
Time Limit Exceeded

input:

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

output:


result:


Test #37:

score: 0
Time Limit Exceeded

input:

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

output:


result:


Test #38:

score: 0
Time Limit Exceeded

input:

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

output:


result:


Test #39:

score: 0
Time Limit Exceeded

input:

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

output:


result:


Test #40:

score: 0
Time Limit Exceeded

input:

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

output:


result:


Test #41:

score: 0
Time Limit Exceeded

input:

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

output:


result:


Test #42:

score: 0
Time Limit Exceeded

input:

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

output:


result:


Test #43:

score: 0
Time Limit Exceeded

input:

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

output:


result:


Test #44:

score: 2
Accepted
time: 4989ms
memory: 120916kb

input:

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

output:

2934715875 2934760198 2934764898 2934834174 2934902091 2934948374 2935012022 2935029392 2934984052 2934909487 2934815542 2934846139 2934868671 2934923969 2934985655 2935006553 2935006553 2935006553 2935006553 2934932004 2934884866 2934895565 2934895565 2934845242 2934869041 2934919247 2934942033 293...

result:

ok 66667 numbers

Test #45:

score: 0
Time Limit Exceeded

input:

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

output:


result:


Test #46:

score: 0
Time Limit Exceeded

input:

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

output:


result:


Test #47:

score: 0
Time Limit Exceeded

input:

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

output:


result:


Test #48:

score: 0
Time Limit Exceeded

input:

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

output:


result:


Test #49:

score: 0
Time Limit Exceeded

input:

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

output:


result:


Test #50:

score: 0
Time Limit Exceeded

input:

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

output:


result: