QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#699069#64. NaanTheZone100 ✓239ms97900kbC++231.4kb2024-11-02 00:36:402024-11-02 00:36:42

Judging History

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

  • [2024-11-02 00:36:42]
  • 评测
  • 测评结果:100
  • 用时:239ms
  • 内存:97900kb
  • [2024-11-02 00:36:40]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std; 
typedef long long i64; 
typedef __int128 lll; 

int n, L, c[2005]; 
i64 v[2005][2005]; 
struct Frac {
    i64 x, y; 
    Frac(i64 x = 1, i64 y = 0) : x(x), y(y) {}
    bool operator< (const Frac &a) const { return (lll)x * a.y < (lll)a.x * y; }
    bool operator>= (const Frac &a) const { return (lll)x * a.y >= (lll)a.x * y; }
} a[2005][2005]; // 第 i 个人的第 j 等分段在哪里结束

int main(void) {
    ios::sync_with_stdio(0); 
    cin >> n >> L; 
    for (int i = 1; i <= n; ++i) for (int j = 1; j <= L; ++j) cin >> v[i][j]; 
    for (int id = 1; id <= n; ++id) {
        i64 s = 0, cur = 0; 
        for (int i = 1; i <= L; ++i) s += v[id][i]; 
        int j = 1; 
        for (int i = 1; i <= L; ++i) {
            while (j <= n && Frac(cur + v[id][i], 1) >= Frac(s * j, n))
                a[id][j] = Frac(s * j - cur * n + n * v[id][i] * (i - 1), n * v[id][i]), 
                ++j; 
            if (j > n) break; 
            cur += v[id][i]; 
        }
    }
    static bool vis[2005]; memset(vis, 0, sizeof vis); 
    for (int i = 1; i <= n; ++i) {
        Frac res; int t = 0; 
        for (int j = 1; j <= n; ++j) if (!vis[j] && a[j][i] < res) 
            res = a[j][i], t = j; 
        vis[t] = 1; c[i] = t; 
        if (i != n) cout << res.x << " " << res.y << "\n"; 
    }
    for (int i = 1; i <= n; ++i) cout << c[i] << " \n"[i == n]; 
    return 0; 
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 5
Accepted

Test #1:

score: 5
Accepted
time: 4ms
memory: 68048kb

input:

2 1516
42058 25892 51128 40494 78380 30332 47660 58339 90812 50469 28184 75581 61837 25051 90975 98279 81022 90217 31015 72984 89884 68399 47215 10071 43418 61089 91302 96661 47701 86531 26050 80503 54870 1405 71971 39883 82485 66816 115 49358 86761 24392 32521 87048 19107 56752 23862 96755 80318 44...

output:

118534088 158076
2 1

result:

ok good plan

Test #2:

score: 5
Accepted
time: 4ms
memory: 68052kb

input:

2 1695
76378 25507 49544 44950 65160 78873 9386 2835 83577 43277 76229 211 44539 72155 22877 94528 90143 3059 2545 54142 93915 38121 21660 42212 2905 22170 43789 49582 23309 23087 21879 45961 28979 2149 83758 55646 64230 18591 99255 85995 12089 33270 72149 71120 93645 42211 83004 67031 30337 58759 8...

output:

92106216 108896
1 2

result:

ok good plan

Test #3:

score: 5
Accepted
time: 8ms
memory: 67624kb

input:

2 1896
5656 8488 83550 73597 66974 30814 60595 60681 58121 15839 43067 39354 72302 99482 94940 54418 44486 26825 3593 2745 46490 31847 38002 89179 52576 56052 23613 2386 32515 13670 51023 99869 67448 18185 89358 79676 73441 90660 76289 78975 35379 98098 96191 16119 75401 71516 46141 53036 49002 9248...

output:

131353113 140046
1 2

result:

ok good plan

Test #4:

score: 5
Accepted
time: 0ms
memory: 68564kb

input:

2 1089
5 4 5 1 5 3 2 4 5 5 1 3 3 1 2 5 4 1 5 5 5 3 1 2 2 2 1 5 2 92110 1 3 2 4 1 1 1 5 2 4 2 3 4 5 2 1 5 3 68199 92895 2 3 2 2 4 3 4 5 2 21113 2 3 2 3 4 2 3 2 3 5 1 2 4 3 4 2 2 4 3 1 5 1 3 2 2 3 3 5 1 2 5 4 5 4 5 2 3 2 5 3 1 1 4 1 3 1 3 4 3 3 2 1 5 3 4 4 5 4 4 4 5 2 5 1 5 4 2 2 3 1 4 1 2 31268 5 1 5...

output:

48326578 108462
2 1

result:

ok good plan

Test #5:

score: 5
Accepted
time: 6ms
memory: 68288kb

input:

2 207
2 4 5 2 5 5 4 3 53669 1 3 3 2 4 4 5 3 5 4 4 3 2 4 2 4 3 50596 5 4 4 1 5 2 3 5 4 3 2 5 4 5 1 5 5 1 3 4633 2 1 53463 3 5 5 4 4 2 2 5 2 74695 2 55853 90432 5 5 4 1 1 3 2 5 1 2 3 4 2 5 2 1819 1 5 5 1 4 1 3 3 1 4 1 3 3 33131 1 4 4 3 1 1 3 4 2 3 5934 2 3 2 1 1 3 24906 4 1 5 5 4 2 3 2 2 5 2 1 5 1 1 5...

output:

4476566 60118
2 1

result:

ok good plan

Test #6:

score: 5
Accepted
time: 0ms
memory: 68376kb

input:

2 1484
79520 5 2 1 4 2 4 4 1 5 3 5 1 3 2 3 4 5 2 1 5 5 5 5 3 5 3 1 2 2 4 5 2 4 1 4 5 4 5 29879 36119 5 14571 1 5 5 3 3 2 4 4 5 31580 1 1 1 4 5 4 3 1 4 3 2 5 2 3 1 2 4 4 3 2 35480 1 5 4 4 1 2 2 5 5 2 3 3 4 1 1 4 1 4 5 4 1 1 1 4856 4 3 5 5 5 5 3 3 5571 91607 3273 3 1 4 2 5 63040 5 2 1 3 2 1 2 99930 4 ...

output:

99452768 165386
1 2

result:

ok good plan

Test #7:

score: 5
Accepted
time: 8ms
memory: 67308kb

input:

2 1644
5 2 4 2 2 3 1 4 3 4 1 4 4 5 1 2 5 2 2 3 1 5 3 1 4 5 5 4 2 5 2 4 5 4 3 5 4 5 2 5 1 3 1 5 2 5 3 2 5 3 5 3 4 3 5 2 5 2 69823 3 4 1 2 2 1 4 1 4 5 4 4 2 2 5 5 5 5 4 4 5 4 2 4 5 3 5 1 5 4 5 4 4 5 3 5 2 2 5 5 1 2 1 2 3 4 3 2 5 3 4 3 3 1 1 4 4 1 3 3 2 2 4 3 2 1 1 5 3 4 1 3 2 2 1 4 5 1 5 4 5 5 5 5 1 5...

output:

8173901 139646
1 2

result:

ok good plan

Test #8:

score: 5
Accepted
time: 4ms
memory: 67448kb

input:

2 302
5 3 1 1 1 2 1 2 2 3 5 4 3 3 3 2 2 1 2 5 1 3 4 5 2 2 2 2 3 5 5 5 1 1 4 5 3 3 1 2 5 5 5 5 2 1 1 3 4 5 4 4 4 3 3 1 4 2 5 4 2 1 2 4 4 1 1 3 3 2 2 4 1 2 3 5 4 5 3 2 2 5 4 2 1 3 4 3 2 4 5 2 1 2 3 4 1 4 4 3 2 5 2 5 2 2 4 2 5 3 1 2 3 4 5 1 2 2 5 1 1 1 2 5 5 4 5 5 2 1 5 4 1 4 2 2 2 1 1 2 2 5 1 5 2 2 5 ...

output:

24245040 88650
1 2

result:

ok good plan

Test #9:

score: 5
Accepted
time: 0ms
memory: 66752kb

input:

2 1925
4 2 4 4 3 1 3 5 4 5 3 4 5 4 2 4 2 2 4 3 5 3 2 4 1 4 2 5 5 3 5 3 2 2 4 5 5 3 2 4 3 4 3 5 3 3 3 2 2 1 2 2 5 4 1 5 3 3 3 5 1 5 2 1 3 3 4 1 2 1 3 2 1 5 4 5 4 5 5 5 4 5 2 1 1 3 2 4 4 2 2 4 3 4 1 2 5 1 4 3 4 5 3 1 1 1 2 4 1 1 1 3 2 5 3 3 5 4 4 3 3 4 4 4 3 4 1 2 5 2 4 1 4 5 3 1 4 1 4 4 4 3 3 1 3 1 3...

output:

10770755 54790
1 2

result:

ok good plan

Test #10:

score: 5
Accepted
time: 4ms
memory: 68556kb

input:

2 1800
19199 26563 12624 27089 2367 1315 38661 2893 38135 29193 24722 6049 22355 1578 9731 9994 33401 6312 29193 15780 34190 26037 30245 12361 1578 28404 13939 17621 22618 31560 17884 21303 10783 30508 30245 19199 17621 35768 23407 526 34979 19988 25774 9205 8153 30245 38135 17358 4734 17358 16306 2...

output:

59495071 65224
1 2

result:

ok good plan

Test #11:

score: 5
Accepted
time: 0ms
memory: 66972kb

input:

2 2000
4192 45064 45850 23842 8384 20436 262 26986 64190 68120 59212 39038 58688 62356 62880 29344 50304 21222 3930 53186 47160 40610 9170 37990 20960 3930 50042 28820 30916 42968 9170 25938 9432 55020 8384 59474 1572 32226 54758 39562 4716 45326 46898 8646 29606 29606 40086 36156 42706 55544 30916 ...

output:

124644142 123140
1 2

result:

ok good plan

Test #12:

score: 5
Accepted
time: 3ms
memory: 67212kb

input:

2 1998
56448 17024 54656 74816 41216 22848 70784 12544 46592 51968 37184 41664 35392 25984 10304 11648 41216 62720 36736 80192 37632 65856 57344 48832 44800 17920 13440 4480 42560 68992 8512 21952 67200 50176 73024 7616 17920 45696 44352 68096 14336 38976 35392 50624 53312 50176 33152 67648 76160 41...

output:

79219840 80640
1 2

result:

ok good plan

Test #13:

score: 5
Accepted
time: 12ms
memory: 67008kb

input:

2 1995
49236 61172 13055 80941 18650 50755 87982 10487 42890 46618 76856 55914 48870 3733 54114 85027 54442 60053 62664 71616 83179 20142 70497 11936 1119 68645 15657 63767 69757 50361 59307 53712 89147 84666 61548 54433 65309 42865 65671 28348 15293 76838 10071 3357 28721 91385 9698 41023 70504 443...

output:

4574282 4554
2 1

result:

ok good plan

Test #14:

score: 5
Accepted
time: 4ms
memory: 68312kb

input:

2 2000
16800 49200 83600 75200 26106 56355 35939 5600 73609 72391 4400 78000 80000 83600 27200 30000 78800 65200 30800 11200 22000 52400 8800 65200 33200 12800 64370 70830 36400 3600 34400 51200 72333 16867 46800 57600 38000 38000 18400 11154 24046 79200 24400 55200 58800 26458 75542 79200 6400 4760...

output:

115521200 115200
1 2

result:

ok good plan

Subtask #2:

score: 24
Accepted

Test #15:

score: 24
Accepted
time: 6ms
memory: 67436kb

input:

2 1168
4 10 7 6 10 3 9 5 7 10 9 7 9 1 5 9 8 5 3 4 5 2 10 7 6 2 4 5 2 4 4 8 10 1 2 9 1 3 6 6 3 8 8 1 8 4 5 6 7 9 2 2 3 2 8 9 4 7 8 9 8 6 8 4 6 3 5 4 5 1 5 5 10 8 2 4 8 1 9 1 7 6 10 4 4 2 3 4 6 3 2 9 1 10 3 8 8 10 8 1 8 10 8 6 1 1 3 8 2 6 8 6 8 9 8 1 7 6 9 3 2 1 5 2 8 6 4 4 1 2 9 2 6 6 8 2 4 2 2 4 6 4...

output:

5696 10
2 1

result:

ok good plan

Test #16:

score: 24
Accepted
time: 12ms
memory: 67436kb

input:

4 1194
4 10 8 8 5 9 8 6 2 5 10 6 4 7 2 4 8 5 4 10 6 5 1 6 5 3 10 7 6 9 4 10 7 4 5 10 7 1 9 5 3 5 3 7 7 5 5 4 7 9 1 7 9 10 8 10 7 9 8 3 8 7 6 3 10 9 8 3 2 2 4 4 8 4 10 1 4 9 6 7 9 7 2 1 10 5 6 2 6 4 2 7 7 7 9 10 9 1 6 7 9 6 5 3 3 9 1 8 10 1 2 3 9 9 10 7 6 5 6 8 3 10 2 10 5 1 2 7 10 1 1 4 8 2 5 3 1 2 ...

output:

5796 20
21354 36
17818 20
1 4 3 2

result:

ok good plan

Test #17:

score: 24
Accepted
time: 8ms
memory: 67104kb

input:

6 1087
5 2 10 1 6 4 9 2 4 4 3 1 5 1 6 1 4 5 10 1 2 8 1 10 6 3 9 8 4 9 3 7 6 9 4 4 8 6 7 7 7 9 5 7 4 1 8 2 9 10 7 2 4 4 1 5 6 4 2 1 7 1 4 3 6 8 10 7 10 10 7 3 5 2 10 5 8 1 2 2 3 4 3 5 5 2 1 4 1 5 1 6 1 7 5 10 3 5 8 4 4 7 10 9 5 8 7 4 3 1 9 1 6 6 2 7 10 8 4 2 10 6 7 9 4 1 2 7 4 9 8 10 7 4 8 1 6 9 6 2 ...

output:

7311 42
19280 54
9783 18
26158 36
54589 60
2 5 1 6 4 3

result:

ok good plan

Test #18:

score: 24
Accepted
time: 0ms
memory: 67104kb

input:

6 1548
2 10 5 8 1 2 10 9 1 5 5 3 2 4 2 2 9 4 3 4 2 10 6 7 10 2 6 5 8 7 5 2 6 8 10 5 6 9 5 5 8 9 8 10 2 6 1 10 3 6 7 5 5 5 6 7 8 5 5 2 1 4 10 5 2 5 8 9 4 7 1 9 4 2 3 9 9 3 10 3 1 1 2 8 6 10 3 2 9 5 5 8 1 1 1 4 1 6 5 4 3 5 8 10 10 1 7 8 10 6 3 5 10 2 6 4 4 1 5 6 9 10 4 3 2 6 8 7 5 10 10 10 4 7 1 7 3 6...

output:

14987 60
12186 24
41517 54
36706 36
61843 48
6 3 2 4 5 1

result:

ok good plan

Test #19:

score: 24
Accepted
time: 8ms
memory: 67584kb

input:

6 1222
9 4 8 4 7 7 1 8 2 6 9 7 8 3 5 2 5 2 10 3 7 6 5 9 7 8 2 2 1 8 6 1 5 6 5 7 10 4 7 8 9 5 6 8 7 8 6 3 7 6 7 5 6 8 4 4 2 5 2 7 2 4 5 10 3 6 6 7 10 6 1 3 2 8 10 5 6 3 7 3 7 4 7 10 10 8 3 6 5 6 9 10 3 6 10 5 5 2 1 7 3 8 8 5 2 9 5 6 4 5 6 8 5 6 9 1 2 10 4 2 10 10 1 9 5 3 6 8 6 5 1 5 1 4 10 10 10 4 5 ...

output:

2338 12
19080 48
33222 54
48918 60
61262 60
6 1 4 2 3 5

result:

ok good plan

Test #20:

score: 24
Accepted
time: 4ms
memory: 68416kb

input:

4 1157
3 2 4 4 4 1 4 1 3 3 3 5 3 5 3 3 6 2 3 2 2 4 2 2 5 1 5 1 5 1 5 2 2 3 1 2 4 2 5 5 2 2 2 2 1 5 3 4 1 5 3 3 2 3 5 4 4 4 5 4 1 3 4 2 3 1 3 5 5 3 4 4 5 4 5 4 2 1 4 1 1 4 2 4 3 4 1 5 5 4 1 4 3 2 3 4 5 3 3 1 3 5 4 5 1 2 3 1 4 5 5 4 2 5 2 2 2 3 5 3 2 2 5 4 5 4 3 1 4 3 2 1 2 1 2 6 4 2 1 3 4 5 4 2 5 1 3...

output:

2262 8
18202 32
17324 20
1 4 3 2

result:

ok good plan

Test #21:

score: 24
Accepted
time: 4ms
memory: 67664kb

input:

2 1248
2 4 3 5 4 2 4 1 3 2 5 5 4 5 3 2 4 2 4 4 4 2 1 3 4 1 3 5 3 2 2 4 4 1 4 1 3 9 5 1 4 4 3 1 1 5 8 5 1 10 5 5 5 2 4 1 6 2 5 4 1 4 3 4 1 1 4 2 1 5 9 4 4 1 1 5 3 5 4 2 5 2 3 4 1 2 2 1 5 2 5 1 4 5 4 4 4 1 2 4 5 4 2 5 4 1 10 3 2 5 3 2 2 3 5 3 5 1 3 2 3 3 1 5 5 4 3 5 4 2 2 2 2 5 4 1 2 5 5 2 5 3 2 4 7 4...

output:

3736 6
2 1

result:

ok good plan

Test #22:

score: 24
Accepted
time: 4ms
memory: 66596kb

input:

6 474
3 3 2 2 2 5 5 5 3 1 4 2 5 3 5 5 1 5 3 2 5 3 5 3 2 1 1 1 3 5 4 1 4 5 1 3 3 2 4 1 3 3 1 2 2 5 1 5 5 3 7 5 4 10 5 2 5 1 5 2 4 5 1 1 5 4 3 3 5 1 5 1 1 4 3 5 1 2 7 4 4 4 4 2 3 5 5 1 2 5 4 3 4 3 1 3 9 5 2 1 3 2 5 5 4 5 3 2 3 4 5 3 8 2 3 3 4 5 5 3 5 1 3 4 4 3 3 5 2 5 5 1 2 1 5 7 1 4 1 4 5 2 1 4 4 3 3...

output:

1301 18
2630 18
4080 18
5490 18
11759 30
6 1 4 3 2 5

result:

ok good plan

Test #23:

score: 24
Accepted
time: 6ms
memory: 68472kb

input:

6 1782
1 4 5 2 3 3 3 5 3 5 3 5 1 4 2 5 3 3 3 3 1 3 1 1 5 2 3 1 1 4 4 2 3 7 1 1 2 5 5 2 3 4 4 3 2 5 2 4 4 3 2 2 3 5 2 5 3 1 2 2 4 4 2 1 2 2 1 2 4 1 4 3 3 2 4 5 1 5 1 2 5 3 3 4 3 1 9 5 3 5 5 2 2 2 1 5 3 5 2 5 2 1 5 2 2 5 5 2 1 3 4 2 2 2 4 2 5 4 2 4 5 1 1 2 5 2 1 2 2 5 2 5 3 1 4 4 4 2 3 3 1 2 2 2 4 2 5...

output:

8492 30
10346 18
15786 18
35566 30
26802 18
4 3 2 5 1 6

result:

ok good plan

Test #24:

score: 24
Accepted
time: 0ms
memory: 67352kb

input:

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

output:

3303 12
10042 18
10098 12
33540 30
33500 24
6 5 2 3 1 4

result:

ok good plan

Test #25:

score: 24
Accepted
time: 4ms
memory: 67368kb

input:

6 1095
5 1 5 2 5 4 1 1 3 4 3 3 2 5 2 3 3 2 2 2 5 1 3 9 2 2 1 2 3 3 2 2 2 2 2 2 5 3 2 2 2 2 2 1 4 1 1 5 2 1 8 1 5 3 2 5 3 2 3 4 4 1 1 3 3 5 5 3 5 1 4 2 3 2 3 5 2 3 3 4 2 2 3 5 2 1 5 4 1 1 3 3 3 1 3 1 4 1 3 3 8 5 4 5 4 1 1 1 1 4 2 3 1 1 2 3 4 2 1 4 2 2 3 1 2 4 1 3 3 5 4 2 4 4 2 2 5 3 5 4 3 5 4 1 1 5 5...

output:

5119 30
10864 30
9936 18
13208 18
27377 30
4 3 5 6 2 1

result:

ok good plan

Test #26:

score: 24
Accepted
time: 3ms
memory: 68092kb

input:

4 61
1 3 3 5 2 4 3 2 3 5 4 4 1 5 5 5 3 4 5 5 1 5 5 4 2 2 1 5 2 2 2 1 2 4 4 5 5 3 2 2 1 1 5 2 1 5 5 2 3 4 5 4 1 1 5 1 1 5 1 1 4
2 2 5 4 1 1 4 4 2 1 1 2 1 2 3 3 3 5 4 1 4 1 1 5 5 2 4 5 4 4 5 1 4 4 1 2 5 4 1 4 5 4 2 3 2 4 2 4 3 1 5 4 1 4 5 3 2 10 5 3 3
1 5 3 2 1 1 5 3 3 5 4 3 1 4 4 5 4 2 5 2 1 4 2 2 3 ...

output:

289 20
456 16
580 12
1 4 2 3

result:

ok good plan

Test #27:

score: 24
Accepted
time: 17ms
memory: 66904kb

input:

4 1361
3 4 1 5 5 2 1 2 2 2 4 1 5 3 4 2 3 4 5 2 1 1 3 5 1 2 1 1 1 2 4 5 4 5 4 3 4 5 3 1 2 2 2 2 2 2 5 5 3 1 1 4 2 2 5 4 4 5 3 5 5 4 1 4 1 3 2 4 4 2 4 5 5 3 4 4 5 1 4 3 4 1 3 2 4 1 1 3 3 2 2 3 5 5 3 4 4 4 1 2 4 2 2 1 5 2 4 2 2 5 3 5 3 3 2 2 5 2 5 5 5 5 3 2 2 2 1 3 5 4 4 4 2 2 3 2 4 3 2 4 4 1 1 1 4 1 1...

output:

4023 12
13494 20
8193 8
1 2 3 4

result:

ok good plan

Test #28:

score: 24
Accepted
time: 4ms
memory: 68064kb

input:

6 1703
1 5 2 5 2 1 5 5 2 2 2 2 3 5 4 2 4 2 4 2 5 2 1 3 1 4 1 5 4 1 5 2 2 3 5 2 4 4 5 5 5 5 4 1 1 3 2 2 4 1 1 3 3 3 4 4 5 3 5 4 1 1 2 1 4 3 4 2 2 1 1 2 3 2 1 3 1 3 2 5 2 2 1 2 3 2 2 4 4 1 2 2 1 4 4 3 3 5 1 4 4 4 4 4 1 3 1 5 1 4 1 2 5 3 2 2 3 4 1 3 4 2 3 2 1 2 4 3 2 5 5 2 3 4 3 5 4 1 1 5 3 4 1 2 2 2 3...

output:

8503 30
6760 12
5091 6
34054 30
42731 30
6 3 1 4 5 2

result:

ok good plan

Test #29:

score: 24
Accepted
time: 4ms
memory: 67540kb

input:

6 1454
5 1 5 1 5 2 3 3 5 4 3 3 4 2 1 3 3 3 2 4 2 4 5 5 1 3 2 4 3 5 2 3 3 3 3 1 3 3 1 3 3 1 3 2 2 5 1 3 4 2 1 2 3 2 1 1 4 5 1 1 3 2 4 5 3 1 3 1 1 5 4 5 4 2 1 5 4 3 4 1 5 2 2 2 5 5 3 1 2 2 4 5 3 5 1 5 1 1 5 3 1 2 5 4 1 2 3 1 1 3 1 3 2 3 4 4 1 5 1 2 3 1 5 1 4 1 1 1 1 1 4 1 4 1 3 3 3 3 1 2 5 2 3 5 5 5 1...

output:

5598 24
13978 30
13134 18
17390 18
36293 30
2 4 6 5 1 3

result:

ok good plan

Test #30:

score: 24
Accepted
time: 13ms
memory: 66816kb

input:

6 1806
1 4 4 4 4 5 5 1 1 2 4 2 1 5 5 5 3 1 2 3 2 5 2 4 2 4 2 5 3 2 5 4 2 4 4 3 1 1 5 4 2 3 4 3 3 5 3 2 3 5 4 1 1 1 2 1 4 2 5 4 5 3 5 2 4 1 3 3 5 3 3 5 1 3 5 2 1 3 5 3 4 2 1 5 4 1 4 4 2 1 5 1 5 1 5 3 3 1 2 5 4 2 1 3 3 1 3 1 1 4 5 3 4 2 4 1 1 3 4 4 2 4 2 3 1 2 4 5 5 4 1 2 3 2 1 5 4 1 3 2 1 4 4 2 2 4 5...

output:

7100 24
3580 6
26877 30
28942 24
36004 24
4 3 5 2 6 1

result:

ok good plan

Test #31:

score: 24
Accepted
time: 6ms
memory: 66884kb

input:

6 1623
2 3 3 3 1 2 2 3 4 2 4 5 2 2 1 2 3 3 1 3 1 5 3 3 5 2 1 1 1 5 3 5 4 2 3 4 2 5 3 4 3 3 3 5 4 4 5 4 4 5 3 5 2 3 2 5 5 3 3 5 3 3 4 2 1 3 2 5 1 5 4 4 2 2 5 3 1 5 3 4 4 2 4 2 1 3 3 4 2 2 1 2 5 2 3 4 4 4 5 2 5 4 5 5 5 5 5 5 1 1 1 3 5 2 2 1 3 4 2 5 4 3 5 5 5 2 3 2 2 3 2 5 2 4 3 4 3 1 4 1 1 1 2 5 1 1 2...

output:

7756 30
12826 24
19422 24
19410 18
32390 24
3 5 2 1 6 4

result:

ok good plan

Test #32:

score: 24
Accepted
time: 0ms
memory: 67484kb

input:

6 1993
2 2 2 2 2 1 2 2 2 2 1 2 2 2 1 2 2 2 1 1 1 2 1 2 1 1 2 2 2 2 2 2 2 2 1 2 2 2 2 1 2 2 1 1 1 1 2 2 1 2 2 1 2 1 2 1 2 2 2 1 1 2 2 2 2 2 2 1 2 1 1 1 1 1 2 2 1 1 1 1 1 1 2 1 1 1 1 2 2 2 2 1 1 2 1 2 2 1 1 1 2 2 1 2 2 2 1 2 1 2 1 2 1 2 1 2 2 2 1 2 2 2 2 2 2 2 2 1 1 2 2 2 2 1 1 2 2 2 1 2 1 2 1 2 2 1 1...

output:

3812 12
7822 12
23712 24
39640 30
49700 30
1 2 3 4 5 6

result:

ok good plan

Test #33:

score: 24
Accepted
time: 8ms
memory: 67008kb

input:

6 2000
6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6...

output:

12000 36
4000 6
36000 36
8000 6
10000 6
1 2 3 4 5 6

result:

ok good plan

Test #34:

score: 24
Accepted
time: 3ms
memory: 67228kb

input:

5 1995
7 6 1 5 2 6 3 6 6 2 7 3 2 2 10 3 3 10 3 6 5 3 7 6 8 4 6 1 8 3 1 8 4 6 7 1 3 8 4 3 9 3 10 2 3 6 3 3 6 3 6 6 3 5 6 1 3 9 3 3 2 9 8 5 4 2 3 3 3 3 3 8 4 3 3 7 8 6 7 2 4 6 2 9 6 9 3 1 1 3 9 1 4 10 1 6 6 4 2 6 3 3 3 2 3 1 6 7 8 6 6 3 8 4 2 4 9 5 1 6 3 5 8 6 2 2 3 1 3 6 3 6 3 3 6 6 5 2 7 10 3 8 6 1 ...

output:

3924 10
23772 30
23624 20
47424 30
5 1 2 3 4

result:

ok good plan

Test #35:

score: 24
Accepted
time: 0ms
memory: 68456kb

input:

6 2000
7 1 4 8 4 8 4 2 6 8 1 7 10 10 4 8 4 8 8 8 8 4 8 4 4 10 6 8 8 8 4 10 2 8 8 8 4 8 4 8 4 4 8 8 6 4 10 8 5 7 4 6 2 8 4 7 5 8 8 10 6 8 4 4 4 4 4 8 9 7 8 8 4 4 8 8 8 4 9 10 9 5 5 6 2 1 5 4 8 8 8 4 6 2 8 4 8 4 2 9 3 6 4 6 6 8 4 4 4 4 8 8 9 5 2 8 10 8 10 1 1 10 4 4 8 4 8 7 1 8 8 4 8 8 8 4 4 8 8 4 5 7...

output:

15692 48
39710 60
29745 30
40114 30
79948 48
1 2 3 4 5 6

result:

ok good plan

Test #36:

score: 24
Accepted
time: 0ms
memory: 66536kb

input:

6 2000
9 9 9 9 9 9 10 8 9 9 9 10 8 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 8 8 8 9 10 10 10 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 10 8 9 9 9 9 9 9 9 9 9 9 9 9 9 10 8 9 9 9 9 9 9 ...

output:

18000 54
16000 24
12000 12
48000 36
9998 6
1 2 3 4 6 5

result:

ok good plan

Test #37:

score: 24
Accepted
time: 3ms
memory: 66800kb

input:

3 8
1 2 1 2 2 1 2 1
2 1 2 1 1 2 1 2
2 4 4 2 2 4 2 4

output:

15 6
30 6
2 1 3

result:

ok good plan

Test #38:

score: 24
Accepted
time: 4ms
memory: 67024kb

input:

5 1843
10 2 10 6 7 5 10 6 10 9 10 2 8 6 6 3 10 10 9 8 9 4 10 4 10 6 8 10 5 8 4 10 5 10 10 10 10 10 9 9 8 3 6 7 3 10 10 10 5 10 10 5 10 10 10 10 10 5 10 10 5 10 10 10 10 10 5 10 10 10 10 6 10 9 10 10 5 9 10 6 10 8 7 4 3 7 3 8 5 10 10 10 6 4 10 10 10 10 10 10 5 10 10 10 10 10 7 8 10 10 10 10 10 5 10 1...

output:

9050 25
18200 25
21910 20
14720 10
1 2 3 4 5

result:

ok good plan

Test #39:

score: 24
Accepted
time: 0ms
memory: 66480kb

input:

4 1744
8 5 5 10 6 8 10 6 2 1 10 7 4 5 7 5 1 10 4 4 1 10 5 10 3 10 3 2 5 8 3 4 8 4 5 3 10 2 10 10 5 5 6 3 10 10 3 2 8 8 4 10 6 8 10 8 10 3 5 4 8 8 8 10 5 10 2 9 9 4 7 4 10 5 6 7 10 7 6 2 10 9 4 4 8 8 10 6 10 5 7 9 2 10 2 3 10 9 7 10 2 5 6 5 10 4 3 2 10 1 3 9 10 2 8 5 9 7 4 6 3 8 6 8 4 9 10 2 10 5 10 ...

output:

13708 32
34170 40
10397 8
1 2 3 4

result:

ok good plan

Test #40:

score: 24
Accepted
time: 0ms
memory: 67116kb

input:

2 1752
10 5 10 7 4 9 10 8 10 4 8 10 10 1 9 10 9 9 7 5 10 10 10 10 5 10 5 10 5 10 10 10 6 7 10 5 8 8 5 2 7 3 10 4 10 10 5 10 10 10 10 10 6 7 7 5 5 10 10 5 10 10 8 7 8 10 10 7 10 10 5 7 5 3 10 10 2 6 7 10 10 6 9 10 4 1 10 6 10 10 4 6 10 10 6 10 3 10 10 10 10 9 4 7 10 10 10 10 10 10 10 10 10 10 8 4 8 1...

output:

8715 10
1 2

result:

ok good plan

Test #41:

score: 24
Accepted
time: 3ms
memory: 68368kb

input:

5 1787
9 1 1 10 1 7 8 2 5 2 5 2 10 4 3 2 9 2 4 2 6 10 2 10 1 4 10 3 8 1 4 4 1 7 4 1 3 1 7 2 3 3 3 5 7 5 5 6 10 7 5 4 3 4 8 5 3 2 1 8 2 2 7 5 4 7 1 2 3 10 3 5 6 8 3 5 7 9 3 8 3 2 6 6 3 10 3 8 1 2 3 10 1 8 6 6 4 7 2 3 6 5 1 3 4 10 3 1 9 1 5 7 3 1 4 1 6 6 1 5 4 6 4 6 1 6 6 1 7 3 7 8 3 7 4 4 1 2 5 6 7 4...

output:

5268 15
35285 50
21156 20
14208 10
1 2 3 4 5

result:

ok good plan

Subtask #3:

score: 71
Accepted

Test #42:

score: 71
Accepted
time: 31ms
memory: 75036kb

input:

563 467
8049 85539 27182 28071 94216 41847 50021 12220 27028 36160 7314 23133 44548 80654 65291 17329 61691 98590 68874 59735 6789 7383 17300 46373 35858 95819 15891 55598 25928 20662 99160 79046 1004 1901 33290 20640 86369 3246 36921 56090 11582 48092 48473 32198 80924 42208 80056 24593 43827 68820...

output:

22348400 56010618
44837792 56053406
68854267 55673944
93215158 53267119
99917765 44916703
132106351 47920308
183546783 56230188
218158172 54890811
185721461 40219031
235965024 44658849
275185257 47523393
260200404 39855333
160597838 22559973
370281996 48089208
449162366 53959609
387220215 42937195
4...

result:

ok good plan

Test #43:

score: 71
Accepted
time: 117ms
memory: 88380kb

input:

1366 1257
52518 80009 48412 20437 83305 26867 69337 71593 7693 67667 97971 70439 22730 28465 48153 21841 82043 29245 52621 14973 60960 33492 98814 50223 73773 41144 3604 73526 5517 6397 76361 21299 35385 31974 51659 51949 13259 2630 82701 11777 34685 80651 10052 8110 36082 39167 88620 98236 3962 503...

output:

61247078 136526236
122140594 136130096
190049789 135653362
247538398 131645518
292191858 123692666
389791788 134620666
435296429 126945112
356913310 83851910
649915178 135918366
720258406 135645166
745467682 125702052
720660012 104012704
882701887 116471990
1118054788 133032008
1213651591 136281722
...

result:

ok good plan

Test #44:

score: 71
Accepted
time: 87ms
memory: 78540kb

input:

690 1866
85792 92334 50551 48051 90530 95125 96811 34670 49217 87825 26495 38978 68460 38876 38857 27803 28417 1805 37912 11112 69602 58726 74906 24482 23332 85335 61653 83174 42938 95270 28423 97755 58360 64911 89830 62190 30657 60857 279 35336 89847 10067 71661 57116 14473 5130 7740 65281 11859 16...

output:

89607952 64788240
209220762 68586000
150235131 30849210
357372926 54998520
563073375 63330270
520432404 46799250
339734492 25467210
634173858 38622750
1267727922 68370720
1299548480 63272310
1269856190 55407690
1328521494 53090670
1877981239 68184420
1141404028 38203230
2066700105 63481380
175261027...

result:

ok good plan

Test #45:

score: 71
Accepted
time: 15ms
memory: 68384kb

input:

120 1641
79533 4616 99240 61065 12661 68564 56220 38422 29259 44471 18466 60650 31236 85811 53461 35262 84149 86402 20219 52122 33390 71427 14689 21333 58989 36999 21782 95540 42645 23935 6410 54667 64280 89935 11448 29739 72262 39244 20237 95857 28793 71700 55654 29845 97155 56453 56786 69842 99775...

output:

101348866 11156760
181235486 9333120
371899446 11911440
320517544 7084440
614279825 11039400
354164346 5101680
916330022 10909560
367198592 3631440
1000523085 8880840
448345540 3602400
1421809328 10249200
1569621888 10286400
1779612485 10667520
730676900 4064280
2153904675 11178120
669577152 3258240...

result:

ok good plan

Test #46:

score: 71
Accepted
time: 123ms
memory: 82284kb

input:

983 1432
37505 3989 77187 24252 51178 28824 31852 32234 32855 8118 54490 55655 70642 5003 53629 99535 74578 40375 76797 70727 14079 79277 2353 26138 19066 42268 36483 95370 28139 95095 78828 87651 16152 31182 68106 52713 83949 11493 93311 56907 42793 1502 34732 92867 16494 69850 49 93950 87357 78602...

output:

69883301 97624679
144919179 97187244
222722806 95995848
242550722 76117622
388654089 98142720
404362746 77449587
504197165 80023081
334580999 44367705
733224954 87360193
862923132 91821047
996021201 90555926
945410514 79086282
1036596857 77235293
1377000245 94336544
1332220549 84017010
1473511662 87...

result:

ok good plan

Test #47:

score: 71
Accepted
time: 52ms
memory: 96016kb

input:

1874 457
3 4 2 5 4 2 3 2 2 71353 2 1 5 34524 4 2 3 5 4 1 4 2 2 5 5 2 2 3 2 3 1 3 2 4 64052 1 3 3 5 5 2 2 4 1 5 2 5 1 16315 3 3 1 93056 2 2 4 2 2 3 2 5 2 2 4 2 4 3 3 3 5 4 5 5 3 1 4 3 2 2 2 1 2 4 4 3 1 96655 1 1 4 1 1 3 5 3 2 5 3 4 2 5 5 1 2 3 1 1 5 4 5 3 3 2 4 1 3 1 1 5 4 5 3 2 2 5 4 2 5 5 3 2 5 5 1...

output:

517251 159527998
1662736 176555162
1950165 130973860
3151604 146706090
4820715 179272462
5830944 180366878
7190449 186491110
7598816 170132964
8760915 172713462
8526800 150800780
8676030 137146816
12623124 160221378
15491333 175621910
16171428 166055140
13945980 131644752
15420608 134971102
21168468...

result:

ok good plan

Test #48:

score: 71
Accepted
time: 21ms
memory: 81856kb

input:

864 590
4 2 5 3 3 3 1 4 2 3 5 3 2 5 3 4 10859 2 1 4 2 5 2 1 4 2 2 5 5 5 3 5 1 4 5 4 3 2 2 4 3 3 4 3 2 1 3 2 2 5 3 4 6444 5 4 2 2 5 2 3 1 22444 4 3 2 1 2 2 2 5 2 4 1 3 3 4 5 2 3 2 1 1 5 2 1 4 2 3 3 5 3 4 1 1 4 30271 1 3 5 2 3 4 1 4 4 2 5 4 4 3 1 4 5 3 2 4 4 2 4746 4 4 4 2 1 34523 4 5 4 2 3 3 1 4 5 4 ...

output:

1030570 49207392
2766866 64805184
2914107 41153184
4770504 47633184
9558085 76005216
9969618 65574144
8272033 45099936
13379920 60626880
16822719 66439008
20052000 70606944
18989047 57119040
16513116 34807104
25717484 48095424
20657728 32925312
15373125 21691584
31217328 39634272
20829845 22299840
9...

result:

ok good plan

Test #49:

score: 71
Accepted
time: 126ms
memory: 97308kb

input:

1971 1294
5 5 1 68003 4 3 5 3 4 4 4 3 1 2 1 5 1 3 27223 3 2 3 4 4 2 4 2 1 3 4 2 1 1 1 1 4 2 5 5 1 1 3 3 5 4 3 3 5 5 2 1 5 4 3 1 5 64583 4 3 3 4 3 1 1 67003 5 3 4 5 3 1 1 1 2 3 2 4 2 5 2 3 2 1 2 3 3 5 3 1 5 4 2 2 1 52723 5 79018 2 3 5 1 2 2 3 1 5 3 1 1 2 1 1 4 3 4 1 5 3 2 24651 4 2 2 3 2 1 2 2 5 2 4 ...

output:

2626452 187757460
5619432 178020720
9323028 196504758
11869564 186566976
15196350 182079009
15025266 149715189
23584225 196835886
23458784 166807701
27513504 172890207
28561060 152931861
35670547 171593289
44320896 194693409
48311159 193694112
52004148 189204174
57726420 191496447
61122768 190047762...

result:

ok good plan

Test #50:

score: 71
Accepted
time: 82ms
memory: 84164kb

input:

1042 1653
1 18448 3 4 5 5 5 5 2 4 3 1 4 4 4 1 5 2 5 2 5 1 2 3 2 5 4 4 3 2 5 2 3 5 4 1 5 3 5 1 5 95349 5 2 6931 64678 3 5 4 1 5 4 5 3 2 3 1 4 1 1 3 5 3 5 4 3 1 3 5 27958 3 2 3 5 4 1 5 2 5 5 62629 1 5 67503 3 2 4 2 3 37459 1 5 5 2 4 4 1 2 5 5 3 2 3 3 5 3 4 6106 3 2 5 3 2 2 3 4 2 2 2 2 2 2 5 5 4 4 2 1 ...

output:

3856263 103973886
6975818 93612238
12763587 92334746
15212980 78228150
20566745 80599742
24096882 77837400
35789747 96857026
31842896 73859044
39277467 75258450
42593620 71645836
54610545 83382924
54698148 72576342
55739697 61247718
144819240 97698962
155225511 101740880
161996428 97646862
155970182...

result:

ok good plan

Test #51:

score: 71
Accepted
time: 141ms
memory: 93408kb

input:

1712 1904
4 1 3 3 4 1 5 4 4 1 3 2 4 2 1 1 5 1 3 3 4 5 2 5 5185 4 3 5 2 1 3 3 1 3 2 1 4 3 4 5 3 5 1 5 5 4 5 5 3 2 1 4 4 4 8382 4 1 64728 1 4 1 3 3 3 3 1 3 1 5 5 2 5 5 3 4 5 5 2 2 2 5 5 5 4 5 3 3 5 3 5 3 5 5 2 4 2 3 4 3 3 3 5 4 5 2 5 5 1 2 2 1 3 1 2 2 5 3 3 5 3 2 1 3 2 2 4 53897 1 4 3 41944 1 3 1 3 5 ...

output:

3452856 136971984
8778862 171182880
14159454 167805104
17281836 149002208
20493305 140755504
25314642 143400544
33871502 163915440
38900200 161056400
43507800 156067632
42499170 130615328
52268909 144170944
47115192 116729296
75170836 169780752
61037718 127787104
71959800 140490144
69288256 12596382...

result:

ok good plan

Test #52:

score: 71
Accepted
time: 101ms
memory: 93724kb

input:

1684 1347
1 5 4 4 1 4 1 4 4 57088 5 2 4 1 4 5 4 2 1 4 4 1 4 2 4 5 81114 1 3 1 3 1 4 2 4 1 1 1 1 4 2 2 1 3 5 2 5 2 2 4 5 5 4 1 3 1 1 1 3 2 5 3 2 4 4 3 3 5 2 1 5 5 4 62532 2 2 1 4 1 5 87652 5 3 5 98954 5 1 4 3 2 2 3 2 3 2 4 3 2 3 1 5 4 94648 72837 3 4 1 2 1 2 1 3 5 3 4 2 5 3 3 2 4 2 3 2 9563 56570 3 3...

output:

2595189 167490640
4935834 135142684
8914968 159227252
13366100 167830808
14973145 148762876
20474712 165658448
23704527 163523136
26123128 156684412
30345795 159562368
30031330 141301072
34827485 147777736
45805476 167131948
46183163 154700660
51782458 158275792
50531355 140198052
57203024 147841728...

result:

ok good plan

Test #53:

score: 71
Accepted
time: 4ms
memory: 67796kb

input:

4 1989
1 4 2 1 2 3 1 1 3 2 4 5 3 5 2 2 1 5 4 1 3 4 2 5 5 3 1 5 3 3 1 3 2 1 3 5 2 3 4 3 2 5 2 5 5 3 4 2 1 4 4 5 1 3 3 4 2 4 2 1 4 1 4 4 5 3 4 3 1 3 1 3 3 4 4 4 1 3 4 5 4 5 2 4 1 4 3 1 1 5 1 1 4 4 4 1 2 2 2 2 2 2 1 1 5 2 3 3 1 2 5 2 4 3 3 4 4 2 4 4 2 2 4 3 5 1 3 5 1 4 2 2 5 2 3 2 2 4 4 2 1 5 5 2 2 5 3...

output:

28374911 33936
280269382 335048
308497740 368676
4 3 2 1

result:

ok good plan

Test #54:

score: 71
Accepted
time: 26ms
memory: 89668kb

input:

1404 108
4 2 3 4 4 2 2 3 2 2 2 3 4 4 3 2 5 1 4 3 2 2 2 4 4 1 4 1 3 5 2 4 3 5 5 2 3 2 4 2 3 3 2 5 2 2 2 3 5 3 2 5 1 5 3 4 5 1 2 1 3 5 2 3 2 5 5 4 5 5 4 2 3 1 2 4 2 3 4 1 3122 4 4 3 5 3 2 3 1 1 4 4 2 4 1 3 2 4 2 1 4 3 3 5 4 2 1 5
1 5 4 1 4 2 1 4 2 2 4 5 2 5 1 2 2 3 5 5 1 5 4 2 2 5 1 4 5 1 5 2 2 5 1 3 ...

output:

375 5616
1136 5616
2517 7020
3820 7020
3595 4212
6072 5616
6910 5616
11084 7020
3501 1404
19618 7020
21965 7020
24192 7020
21983 5616
32110 7020
23394 4212
42772 7020
46663 7020
30780 4212
46857 5616
49064 5616
65355 7020
41906 4212
73526 7020
46752 4212
80438 7020
69992 5616
38475 2808
41272 2808
2...

result:

ok good plan

Test #55:

score: 71
Accepted
time: 93ms
memory: 87452kb

input:

1294 1689
1 3 3 2 3 1 1 4 2 4 4 5 4 4 2 5 5 5 3 5 3 3 2 2 2 1 1 1 4 2 5 3 3 1 5 2 2 3 5 1 4 3 1 3 3 3 5 5 3 5 3 4 4 1 3 5 1 3 4 2 4 4 4 2 5 4 3 3 5 5 5 5 4 2 3 4 4 5 3 1 4 3 3 3 2 4 4 5 2 3 5 5 4 4 1 2 2 1 2 4 5 1 2 3 1 5 2 1 3 4 3 4 3 4 3 2 3 4 1 2 5 4 3 4 3 1 2 5 1 3 4 1 3 5 2 2 2 1 4 5 2 2 2 5 4 ...

output:

5356 6470
10232 5176
19764 6470
27138 5176
31880 5176
53238 6470
59723 6470
14356 1294
79994 6470
93452 6470
86238 5176
98800 5176
129926 6470
145914 6470
154533 6470
135616 5176
108887 3882
155828 5176
125298 3882
87358 2588
186742 5176
197284 5176
265739 6470
165718 3882
172003 3882
242262 5176
12...

result:

ok good plan

Test #56:

score: 71
Accepted
time: 75ms
memory: 86512kb

input:

1206 1397
2 3 4 2 4 2 2 2 2 4 3 1 2 3 3 3 5 3 3 4 4 3 1 1 4 1 4 2 2 3 3 1 3 5 2 2 4 4 5 5 2 4 5 5 1 1 4 5 3 2 4 2 5 1 3 1 3 2 3 4 4 5 2 5 3 3 2 5 4 4 2 2 1 5 3 5 5 5 3 2 1 4 4 4 2 3 1 3 1 3 4 2 2 5 4 3 1 3 4 2 5 1 4 5 4 2 4 5 5 4 2 2 1 1 3 1 1 1 2 2 1 1 2 2 3 5 2 1 1 4 5 1 5 5 2 3 4 1 3 1 1 1 3 2 4 ...

output:

4233 6030
9098 4824
17871 6030
16134 3618
33067 6030
42894 6030
39297 4824
43932 4824
63027 6030
46216 3618
17477 1206
77514 4824
104431 6030
90420 4824
130365 6030
142328 6030
65634 2412
138762 4824
186297 6030
197968 6030
216615 6030
225802 6030
238492 6030
250140 6030
54154 1206
223726 4824
17530...

result:

ok good plan

Test #57:

score: 71
Accepted
time: 95ms
memory: 93492kb

input:

1701 1161
1 3 5 1 3 1 4 3 4 4 3 4 5 3 3 1 2 1 2 3 1 4 3 4 4 1 2 5 4 5 5 2 2 3 2 4 4 2 3 1 4 2 2 5 5 4 4 4 1 4 2 3 2 2 3 3 2 4 3 3 5 3 3 4 2 4 5 4 1 1 5 3 2 1 2 4 2 1 4 5 5 2 5 5 2 4 4 3 3 4 1 2 3 1 5 2 3 1 3 1 3 1 5 4 2 1 1 5 2 4 3 1 4 3 1 1 4 5 4 5 2 4 3 5 3 1 3 4 5 2 1 4 3 5 3 1 4 2 1 1 2 3 4 4 3 ...

output:

3981 8505
5199 5103
14553 8505
17436 6804
23838 6804
7344 1701
34076 6804
47357 8505
48915 6804
65696 8505
72672 8505
82776 8505
91499 8505
77126 6804
103416 8505
110695 8505
114982 8505
126774 8505
27778 1701
117450 6804
159411 8505
166982 8505
108920 5103
190620 8505
82483 3402
169575 6804
136998 ...

result:

ok good plan

Test #58:

score: 71
Accepted
time: 99ms
memory: 85940kb

input:

1117 1900
4 2 2 5 5 2 4 4 3 5 4 5 3 3 5 5 3 4 2 1 2 2 2 5 1 2 4 5 3 5 2 5 3 5 1 3 1 5 1 4 4 5 5 5 3 2 3 1 2 5 2 3 1 5 5 1 3 4 2 4 3 4 1 3 4 3 5 5 1 4 4 1 2 1 3 2 1 5 1 3 3 3 5 3 3 2 2 3 1 2 4 2 2 5 4 1 4 3 5 2 1 1 2 5 5 1 5 2 4 2 3 5 1 3 1 1 4 4 4 4 4 1 4 3 1 5 3 5 3 1 5 5 2 2 2 2 3 5 1 5 2 2 5 1 3 ...

output:

6232 5585
12206 4468
14945 3351
38433 5585
48961 5585
33613 3351
68070 5585
86908 5585
100385 5585
86708 4468
131399 5585
114944 4468
123225 4468
136283 4468
118923 3351
210351 5585
223222 5585
195145 4468
152975 3351
215734 4468
234944 4468
262960 4468
212337 3351
296402 4468
309961 4468
243024 335...

result:

ok good plan

Test #59:

score: 71
Accepted
time: 219ms
memory: 97788kb

input:

2000 1993
20720 19943 37037 36519 48174 62678 39886 49728 32375 5180 61124 5957 36778 42735 1036 45584 15281 19943 39886 60606 11396 24346 8029 30821 55944 27713 35742 27713 31598 33152 5180 44289 2849 7511 18648 44807 42476 39368 11914 55426 5957 6216 36260 24346 54649 4144 9324 54131 51023 26159 2...

output:

61648216 39886000
304387584 116688000
114434424 32994000
218329248 51336000
485747920 98952000
562850816 103576000
505853568 85184000
243338656 36344000
1098389592 148608000
731727360 91000000
49175640 5400000
157705216 15104000
1918927752 175112000
369392608 29252000
797104800 59400000
10648768 704...

result:

ok good plan

Test #60:

score: 71
Accepted
time: 239ms
memory: 97832kb

input:

1998 2000
56826 37422 66759 48510 12705 45738 5775 57981 18480 21483 42273 21714 30261 21483 7854 43428 6237 46200 56133 39963 38115 24717 37884 42735 71379 39501 9933 45738 43890 45738 49665 36498 17325 67683 1155 38115 67683 693 61677 9471 11781 32802 47355 42042 10626 8316 55209 24024 19404 50358...

output:

73223766 113538348
90897300 63116820
233601858 104513382
258824244 92964942
404846856 117062820
7939350 1648350
163788912 28483488
470879232 64191744
1162757430 145935918
39890796 4087908
526406136 48994956
330351840 27220752
651672840 48311640
1325555508 86017896
690305508 40359600
1673496396 93506...

result:

ok good plan

Test #61:

score: 71
Accepted
time: 228ms
memory: 97736kb

input:

1993 1995
56244 38259 44145 43491 38913 10464 44472 52647 30411 3270 49050 16350 26487 34989 64746 17658 39239 47416 15369 22236 24525 981 44145 50358 62130 56244 16022 62457 35317 327 4251 26487 59841 25179 14714 1636 58860 18312 11118 33027 44472 47088 11445 37278 57225 28776 25179 20928 30739 817...

output:

67803123 112094292
917242 701536
1750547 807165
3164123 1076220
3939708 1058283
149407218 32729046
1652736 269055
5608157 811151
896729040 118402137
142905164 17052108
1393253225 136022250
176549976 16143300
8151388 649718
11653397 854997
22583317 1576463
17609858 1185835
23172493 1432967
29494751 1...

result:

ok good plan

Test #62:

score: 71
Accepted
time: 225ms
memory: 97776kb

input:

1999 2000
14373 28746 33537 33537 81447 86238 62283 47910 19163 23956 38328 76656 14373 47910 23955 4791 86238 57492 23955 62283 9582 23955 57492 81447 23955 43120 81444 4794 14372 62283 33537 62283 9582 43119 4791 4791 19164 71865 47910 28746 14373 86238 71865 23955 19164 33537 14374 81449 33534 47...

output:

139868454 67040463
73412181 21227381
199047648 45843067
36184967 7374311
397572405 73007478
1077441152 180197856
405417225 60419775
98990229 13053470
145682 15992
484352000 45033472
35976878 3134432
54509112 4389804
1119657162 81219370
2219628516 138026952
2472624880 148821552
546572313 31736124
446...

result:

ok good plan

Test #63:

score: 71
Accepted
time: 220ms
memory: 97864kb

input:

2000 2000
13325 37375 64675 64350 4550 26975 43875 60125 2275 28600 16900 70525 52000 43875 51350 31525 70850 34775 50700 55900 7800 72799 50701 93600 41275 9750 46150 34450 77675 51025 35750 92950 90675 24700 21775 7475 64674 38026 25675 86452 7148 57850 2925 42575 73775 58500 85475 77025 52650 438...

output:

145751125 74750000
130191600 47760000
96557650 27720000
250502940 46314000
9111625 1350000
211709250 27750000
414247945 42064000
34606040 3038000
775237000 64000000
218652300 16740000
17884460 1264000
867766100 57230000
1444151135 88508000
567919560 33384000
792991525 43368000
853133760 44376000
266...

result:

ok good plan

Test #64:

score: 71
Accepted
time: 178ms
memory: 97900kb

input:

1999 2000
9 5 6 10 4 10 4 10 6 2 10 2 6 8 2 2 8 2 10 8 8 8 4 10 2 9 12 7 4 4 6 10 2 8 8 8 6 10 8 4 2 2 4 8 2 8 6 10 4 10 10 8 2 6 8 2 6 4 3 11 8 6 10 8 6 10 11 3 10 10 8 6 8 4 3 10 7 7 1 4 6 6 4 3 11 8 1 5 4 10 6 8 6 6 6 2 8 8 4 2 6 4 4 2 8 4 10 4 4 10 6 2 4 6 4 2 2 6 2 4 10 6 4 2 2 2 6 10 4 10 8 8 ...

output:

355709 33983
181092 7996
803259 23988
730000 15992
676618 11994
1718688 25987
754692 9995
1063833 11994
407457 3998
465680 3998
3125193 23988
871112 5997
1861599 11994
1977150 11994
2794037 15992
3663628 19990
2330886 11994
830906 3998
3484874 15992
2296764 9995
4828002 19990
6076473 23988
2118740 7...

result:

ok good plan

Test #65:

score: 71
Accepted
time: 181ms
memory: 97840kb

input:

2000 2000
2 10 8 4 8 2 10 4 10 6 10 10 8 6 59358 10 2 2 6 10 2 10 10 8 5 9 10 2 6 9 5 12 10 10 6 8 8 10 4 10 4 10 5 11 5 1 4 10 4 6 10 8 2 4 4 2 4 4 10 8 6 6 10 8 8 2 8 8 6 2 13 1 8 6 6 10 4 8 10 10 4 2 6 8 6 10 10 8 8 4 2 3 11 8 8 2 6 2 6 2 6 2 8 2 10 2 10 4 8 10 8 6 10 6 8 8 8 6 8 4 8 2 8 4 4 4 8 ...

output:

1662124794 118716000
2493632382 178074000
1662718382 118716000
1663015176 118716000
1663311970 118716000
831804382 59358000
1663905558 118716000
1664202352 118716000
832249573 59358000
832397970 59358000
1665092734 118716000
1665389528 118716000
1665686322 118716000
2498974674 178074000
2499419865 1...

result:

ok good plan

Test #66:

score: 71
Accepted
time: 171ms
memory: 97876kb

input:

2000 2000
2 3 3 3 2 1 6 2 4 2 2 4 1 1 4 4 5 3 2 2 3 5 3 2 1 3 4 6 1 1 5 5 4 1 2 5 4 3 1 5 3 2 1 1 4 1 4 4 2 1 2 5 2 5 2 4 3 3 2 5 3 1 4 3 5 4 1 4 1 1 1 5 2 4 2 5 3 2 1 5 3 1 2 1 6 5 5 2 2 5 5 1 1 2 3 6 2 3 3 5 5 4 1 5 2 4 5 5 1 4 4 2 3 2 1 4 1 1 4 1 3 5 5 1 2 1 1 4 3 4 1 5 1 2 1 3 3 5 4 1 4 1 6 2 2 ...

output:

25308 6000
66616 8000
51848 4000
229232 14000
324540 16000
143848 6000
221156 8000
949392 30000
347772 10000
387080 10000
1063164 24000
1049392 22000
627004 12000
556312 10000
597620 10000
126928 2000
538236 8000
868632 12000
2276556 30000
1760480 22000
337468 4000
1042776 12000
1812168 20000
133539...

result:

ok good plan

Test #67:

score: 71
Accepted
time: 73ms
memory: 89520kb

input:

1382 1191
299 138 253 322 23 299 368 391 46 253 437 46 230 345 322 69 207 207 184 299 253 184 460 207 414 115 322 207 414 276 115 138 115 414 322 207 138 276 207 69 230 345 23 115 161 92 161 207 276 299 391 345 207 368 92 207 322 299 138 92 276 460 391 391 230 138 460 230 161 460 391 161 299 46 345 ...

output:

283682 413218
29988 16584
164592 60808
2109440 619136
115020 24876
406576 71864
1388540 221120
3779700 552800
2597940 352410
4452720 563856
5614674 592878
2935460 288838
8375820 787740
1522324 127144
4096300 317860
2522376 186570
12842750 909356
571168 38696
2228160 136818
3223410 186570
404704 2211...

result:

ok good plan

Test #68:

score: 71
Accepted
time: 106ms
memory: 85964kb

input:

1239 1740
156 180 228 144 168 240 12 216 228 96 180 96 156 240 144 84 12 144 60 216 120 84 168 84 204 96 204 144 60 96 132 168 192 36 144 132 108 36 91 5 36 72 168 180 240 72 120 240 120 60 108 84 96 108 96 96 24 204 48 108 180 36 84 204 228 168 96 204 156 84 192 144 24 144 156 228 216 240 120 72 24...

output:

251232 223020
2366688 1129968
3049380 1059345
2804600 693840
754458 148680
5479638 941640
4727912 624456
7691736 918099
465105 49560
6342688 594720
8802180 724815
15686928 1189440
3107421 223020
3432884 225498
1579446 89208
5611034 289926
3777540 185850
18769107 849954
5656616 242844
24856320 101102...

result:

ok good plan

Test #69:

score: 71
Accepted
time: 91ms
memory: 93004kb

input:

1574 1132
81 351 405 5 157 432 432 513 540 297 459 27 297 486 540 54 405 270 486 27 270 351 459 27 432 54 459 243 243 108 81 135 459 513 81 297 54 189 405 270 486 270 486 378 459 54 486 108 297 486 378 189 540 540 81 540 27 432 351 216 189 108 459 378 486 378 81 513 54 486 54 54 81 351 17 145 432 27...

output:

749385 552474
1153330 593398
2207078 897180
3364608 1133280
3960467 780704
2376124 428128
455361 75552
2620832 402944
6505229 931808
1767088 239248
1397406 179436
7467732 912920
539046 62960
10979982 1227720
5479947 571362
6812850 668950
6828696 642192
1458800 121198
6832865 536734
6386288 481644
81...

result:

ok good plan

Test #70:

score: 71
Accepted
time: 143ms
memory: 93216kb

input:

1589 1929
506 230 368 460 828 828 414 184 736 322 598 690 690 552 874 230 644 644 690 230 828 92 598 276 828 460 230 184 322 184 644 414 644 322 460 276 506 92 276 552 506 782 828 322 414 460 874 874 414 276 598 690 690 736 644 874 276 644 414 92 736 184 828 782 690 138 506 368 92 920 598 690 552 73...

output:

492154 365470
1700000 540260
2784863 657846
282628 57204
8077350 1430100
1151688 171612
1491952 177968
3558440 378182
1321398 123942
6610176 572040
14487193 1167915
8887165 667380
9027354 634011
900214 60382
9867582 600642
14270863 823102
12166952 667380
5655709 293965
22862970 1115478
2285485 10328...

result:

ok good plan

Extra Test:

score: 0
Extra Test Passed