QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#392929#64. NaanRafi22100 ✓319ms258860kbC++141.6kb2024-04-17 23:16:582024-04-17 23:16:59

Judging History

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

  • [2024-04-17 23:16:59]
  • 评测
  • 测评结果:100
  • 用时:319ms
  • 内存:258860kb
  • [2024-04-17 23:16:58]
  • 提交

answer

#include <bits/stdc++.h>

#define int long long
#define ll long long
#define ld long double
//#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;
ll infl=1000000000000000007;
int inf=1000000007;
int mod=1000000007;
int mod1=998244353;

const int N=2007;

struct frac
{
    __int128 p,q;
};
bool cmp(frac A,frac B)
{
    return A.p*B.q<=B.p*A.q;
}


int a[N][N];
int P[N][N];
int s[N];
bool odw[N];

vector<pair<frac,int>>V[N];

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            cin>>a[i][j];
            P[i][j]=P[i][j-1]+a[i][j];
            s[i]+=a[i][j];
        }
        int k=0;
        for(int j=1;j<n;j++)
        {
            while(cmp({P[i][k+1],1},{s[i]*j,n})) k++;
            frac X;
            X.p=s[i]*j-P[i][k]*n+k*n*a[i][k+1];
            X.q=n*a[i][k+1];
            V[j].pb({X,i});
        }
    }
    vector<int>ord;
    for(int j=1;j<n;j++)
    {
        frac mn={m+7,1};
        int c=0;
        for(auto [X,i]:V[j])
        {
            if(odw[i]) continue;
            if(cmp(X,mn))
            {
                mn=X;
                c=i;
            }
        }
        ord.pb(c);
        odw[c]=1;
        cout<<(ll)mn.p<<" "<<(ll)mn.q<<endl;
    }
    for(int i=1;i<=n;i++) if(!odw[i]) ord.pb(i);
    for(auto x:ord) cout<<x<<" ";
    cout<<endl;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 5
Accepted

Test #1:

score: 5
Accepted
time: 1ms
memory: 5752kb

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: 0
Accepted
time: 1ms
memory: 5764kb

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: 0
Accepted
time: 1ms
memory: 5760kb

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: 0
Accepted
time: 1ms
memory: 5684kb

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: 0
Accepted
time: 1ms
memory: 5924kb

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: 0
Accepted
time: 1ms
memory: 5920kb

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: 0
Accepted
time: 1ms
memory: 7784kb

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: 0
Accepted
time: 1ms
memory: 5892kb

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: 0
Accepted
time: 1ms
memory: 5700kb

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: 0
Accepted
time: 1ms
memory: 5692kb

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:

55875599 61256
2 1 

result:

ok good plan

Test #11:

score: 0
Accepted
time: 1ms
memory: 5688kb

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:

41865208 41360
2 1 

result:

ok good plan

Test #12:

score: 0
Accepted
time: 1ms
memory: 5752kb

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:

21926920 22320
2 1 

result:

ok good plan

Test #13:

score: 0
Accepted
time: 0ms
memory: 5752kb

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: 0
Accepted
time: 1ms
memory: 5988kb

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:

26281073 26208
2 1 

result:

ok good plan

Subtask #2:

score: 24
Accepted

Test #15:

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

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: 0
Accepted
time: 1ms
memory: 5760kb

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: 0
Accepted
time: 1ms
memory: 6028kb

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: 0
Accepted
time: 0ms
memory: 5816kb

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: 0
Accepted
time: 1ms
memory: 5736kb

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: 0
Accepted
time: 1ms
memory: 6012kb

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: 0
Accepted
time: 1ms
memory: 5748kb

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: 0
Accepted
time: 1ms
memory: 5996kb

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
3660 12
11759 30
6 1 4 3 2 5 

result:

ok good plan

Test #23:

score: 0
Accepted
time: 1ms
memory: 5820kb

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
5262 6
35566 30
8934 6
4 3 2 5 1 6 

result:

ok good plan

Test #24:

score: 0
Accepted
time: 1ms
memory: 5820kb

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
26832 24
33500 24
6 5 2 3 1 4 

result:

ok good plan

Test #25:

score: 0
Accepted
time: 0ms
memory: 5996kb

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
16560 30
13208 18
27377 30
4 3 5 6 2 1 

result:

ok good plan

Test #26:

score: 0
Accepted
time: 1ms
memory: 5672kb

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: 0
Accepted
time: 1ms
memory: 5740kb

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: 0
Accepted
time: 1ms
memory: 5824kb

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: 0
Accepted
time: 1ms
memory: 5984kb

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: 0
Accepted
time: 1ms
memory: 6020kb

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: 0
Accepted
time: 1ms
memory: 6064kb

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: 0
Accepted
time: 1ms
memory: 5760kb

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:

15248 48
39110 60
29640 30
15856 12
9940 6
6 5 4 3 2 1 

result:

ok good plan

Test #33:

score: 0
Accepted
time: 1ms
memory: 5816kb

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:

18000 54
4000 6
6000 6
48000 36
10000 6
6 5 4 3 2 1 

result:

ok good plan

Test #34:

score: 0
Accepted
time: 0ms
memory: 5812kb

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
31696 40
17718 15
63232 40
5 4 3 2 1 

result:

ok good plan

Test #35:

score: 0
Accepted
time: 1ms
memory: 5792kb

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:

19615 60
31768 48
11898 12
72208 54
99935 60
6 5 4 3 2 1 

result:

ok good plan

Test #36:

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

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:

4000 12
28000 42
36000 36
16000 12
100002 60
6 5 4 3 1 2 

result:

ok good plan

Test #37:

score: 0
Accepted
time: 0ms
memory: 5704kb

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:

30 12
15 3
3 1 2 

result:

ok good plan

Test #38:

score: 0
Accepted
time: 1ms
memory: 5752kb

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:

7240 20
3640 5
21910 20
73600 50
5 4 3 2 1 

result:

ok good plan

Test #39:

score: 0
Accepted
time: 0ms
memory: 5720kb

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:

3427 8
6834 8
51985 40
4 3 2 1 

result:

ok good plan

Test #40:

score: 0
Accepted
time: 1ms
memory: 5916kb

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:

6972 8
2 1 

result:

ok good plan

Test #41:

score: 0
Accepted
time: 1ms
memory: 5972kb

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:

7024 20
14114 20
21156 20
35520 25
5 4 3 2 1 

result:

ok good plan

Subtask #3:

score: 71
Accepted

Test #42:

score: 71
Accepted
time: 22ms
memory: 40480kb

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: 0
Accepted
time: 127ms
memory: 156568kb

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: 0
Accepted
time: 68ms
memory: 55068kb

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: 0
Accepted
time: 8ms
memory: 8880kb

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: 0
Accepted
time: 87ms
memory: 81892kb

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: 0
Accepted
time: 112ms
memory: 217304kb

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: 0
Accepted
time: 28ms
memory: 67120kb

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: 0
Accepted
time: 162ms
memory: 251856kb

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: 0
Accepted
time: 92ms
memory: 116672kb

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: 0
Accepted
time: 210ms
memory: 212596kb

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: 0
Accepted
time: 144ms
memory: 206752kb

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: 0
Accepted
time: 1ms
memory: 5788kb

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: 0
Accepted
time: 82ms
memory: 142704kb

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: 0
Accepted
time: 106ms
memory: 149844kb

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: 0
Accepted
time: 94ms
memory: 135532kb

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: 0
Accepted
time: 136ms
memory: 205244kb

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: 0
Accepted
time: 92ms
memory: 124868kb

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: 0
Accepted
time: 319ms
memory: 258860kb

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:

51651208 33418000
115637440 44330000
188767896 54426000
294269856 69192000
505835240 103044000
923180544 169884000
899614584 151492000
800130496 119504000
720906864 97536000
773942400 96250000
75766912 8320000
1222215424 117056000
651711312 59472000
118349088 9372000
1682776800 125400000
15973152 10...

result:

ok good plan

Test #60:

score: 0
Accepted
time: 268ms
memory: 258260kb

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:

316986 491508
46614000 32367600
153583542 68713218
263647056 94697208
288761736 83496420
140791140 29230740
129666222 22549428
728391312 99296604
139850550 17552430
527646438 54071874
1080311100 100549350
282704940 23294682
145373172 10777212
393614736 25542432
1647164628 96303600
1137119346 6353640...

result:

ok good plan

Test #61:

score: 0
Accepted
time: 279ms
memory: 257940kb

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:

80866110 133690440
917242 701536
1746561 805172
3164123 1076220
3939708 1058283
495858738 108622486
1652736 269055
5608157 811151
473881200 62570235
750252111 89523567
146980560 14349600
722547124 66067950
8151388 649718
11653397 854997
16987811 1185835
23470510 1580449
23172493 1432967
29494751 173...

result:

ok good plan

Test #62:

score: 0
Accepted
time: 293ms
memory: 258564kb

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:

64810680 31064460
67459842 19506242
272528544 62766601
120227471 24501743
803962335 147634146
1035703216 173217348
72190422 10758618
98838636 13033480
145682 15992
337980000 31424280
334438121 29137424
161740152 13025484
1190204106 86336810
346021338 21517236
845331620 50878548
125178693 7268364
713...

result:

ok good plan

Test #63:

score: 0
Accepted
time: 314ms
memory: 258816kb

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:

80723700 41400000
20613670 7562000
259326260 74448000
108641060 20086000
100227875 14850000
728279820 95460000
244388955 24816000
237298560 20832000
337228095 27840000
1075628250 82350000
1189316590 84056000
232384820 15326000
1088448885 66708000
389534570 22898000
1774247225 97032000
211630080 1100...

result:

ok good plan

Test #64:

score: 0
Accepted
time: 234ms
memory: 258520kb

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
271638 11994
803259 23988
365000 7996
338309 5997
1718688 25987
754692 9995
1063833 11994
1222371 11994
232840 1999
2083462 15992
2613336 17991
1241066 7996
1977150 11994
2794037 15992
3663628 19990
2330886 11994
2492718 11994
3484874 15992
2296764 9995
4828002 19990
2025491 7996
211874...

result:

ok good plan

Test #65:

score: 0
Accepted
time: 240ms
memory: 258828kb

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:

831062397 59358000
831210794 59358000
831359191 59358000
2494522764 178074000
2494967955 178074000
831804382 59358000
1663905558 118716000
1664202352 118716000
2496748719 178074000
1664795940 118716000
1665092734 118716000
1665389528 118716000
2498529483 178074000
1665983116 118716000
2499419865 178...

result:

ok good plan

Test #66:

score: 0
Accepted
time: 249ms
memory: 258752kb

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
133232 16000
25924 2000
229232 14000
324540 16000
143848 6000
221156 8000
949392 30000
347772 10000
387080 10000
354388 8000
1049392 22000
627004 12000
556312 10000
1792860 30000
126928 2000
1076472 16000
868632 12000
1517704 20000
1760480 22000
337468 4000
1042776 12000
906084 10000
1335...

result:

ok good plan

Test #67:

score: 0
Accepted
time: 114ms
memory: 161072kb

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:

74004 107796
704718 389724
123444 45606
593280 174132
153360 33168
3659184 646776
138854 22112
5896332 862368
3983508 540362
3525070 446386
6478470 684090
3202320 315096
4187910 393870
1555418 129908
7302100 566620
7567128 559710
3825500 270872
10281024 696528
2835840 174132
4512774 261198
9308192 5...

result:

ok good plan

Test #68:

score: 0
Accepted
time: 126ms
memory: 140724kb

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:

753696 669060
2021546 965181
1423044 494361
2874715 711186
5029720 991200
5912241 1015980
7091868 936684
7297288 871017
930210 99120
2774926 260190
5868120 483210
8823897 669060
2762152 198240
2772714 182133
11582604 654192
18127956 936684
10577112 520380
9576075 433650
1212132 52038
21749280 884646...

result:

ok good plan

Test #69:

score: 0
Accepted
time: 129ms
memory: 187992kb

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:

305305 225082
755630 388778
1916673 779130
1682304 566640
5493551 1082912
6429512 1158464
2125018 352576
4422654 679968
6505229 931808
5743036 777556
1863208 239248
8240256 1007360
7546644 881440
10135368 1133280
3321180 346280
3542682 347854
7113225 668950
6043600 502106
6832865 536734
18783200 141...

result:

ok good plan

Test #70:

score: 0
Accepted
time: 172ms
memory: 192240kb

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:

406562 301910
450000 143010
5448645 1287090
5793874 1172682
1453923 257418
3455064 514836
5115264 610176
627960 66738
2202330 206570
6885600 595875
8278396 667380
3808785 286020
17624834 1237831
900214 60382
10963980 667380
15813659 912086
17815894 977235
4432853 230405
25794120 1258488
1371291 6197...

result:

ok good plan

Extra Test:

score: 0
Extra Test Passed