QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#80398#64. Naanlmeowdn100 ✓1973ms98136kbC++142.3kb2023-02-23 16:32:032023-02-23 16:32:05

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-02-23 16:32:05]
  • 评测
  • 测评结果:100
  • 用时:1973ms
  • 内存:98136kb
  • [2023-02-23 16:32:03]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define fi first
#define se second
#define eb emplace_back
#define popc __builtin_popcount
#define sgn(x) ((x)&1?-1:1)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vp;
typedef unsigned long long ull;
typedef long double ld;

int read() {
    int x=0,w=1; char c=getchar(); 
    while(!isdigit(c)) {if(c=='-') w=-1; c=getchar();}
    while(isdigit(c)) {x=x*10+c-'0'; c=getchar();}
    return x*w;
}

const int N=2009;

int n,l,v[N][N],p[N],vst[N];
struct frac {
    int a,b;
    frac(int _a=0,int _b=1) {a=_a,b=_b;}
} x[N][N],y[N];
bool operator < (const frac &x,const frac &y) {
    return 1.*x.a/x.b<1.*y.a/y.b;
}
bool operator > (const frac &x,const frac &y) {
    return 1.*x.a/x.b>1.*y.a/y.b;
}
frac operator + (const frac &x,const frac &y) {
    int c=x.b/__gcd(x.b,y.b)*y.b;
    return frac(c/x.b*x.a+c/y.b*y.a,c);
}
frac operator - (const frac &x,const frac &y) {
    int c=x.b/__gcd(x.b,y.b)*y.b;
    return frac(c/x.b*x.a-c/y.b*y.a,c);
}
frac operator / (const frac &x,const int &a) {
    if(x.a==0) return x;
    int p=x.b*a, g=__gcd(x.a,p);
    return frac(x.a/g,x.b*a/g);
}
frac operator * (const frac &x,const int &a) {
    int p=x.a*a, g=__gcd(x.b,p);
    return frac(x.a*a/g,x.b/g);
}

signed main() {
    n=read(), l=read();
    rep(i,1,n) {
        int sum=0;
        rep(j,1,l) v[i][j]=read(), sum+=v[i][j];
        frac p(sum,n);
        int pos=1; frac rem(1,1);
        rep(j,1,n) {
            frac g=p;
            while(1) {
                frac q=rem*v[i][pos];
                if(q<g) g=g-q, pos++, rem=frac(1,1);
                else {
                    frac u=g/v[i][pos];
                    rem=rem-u, x[i][j]=frac(pos,1)-rem;
                    break;
                }
            }
        }
    }
    rep(j,1,n) {
        int pos=0;
        rep(i,1,n) if(!vst[i]) {
            if(pos==0) pos=i;
            else if(x[i][j]<x[pos][j]) pos=i;
        } vst[pos]=1;
        y[j]=x[pos][j];
        p[j]=pos;
    }
    rep(j,1,n-1) printf("%lld %lld\n",y[j].a,y[j].b);
    rep(j,1,n) printf("%lld ",p[j]); puts("");
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 5
Accepted

Test #1:

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

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:

29633522 39519
2 1 

result:

ok good plan

Test #2:

score: 0
Accepted
time: 12ms
memory: 66572kb

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:

11513277 13612
1 2 

result:

ok good plan

Test #3:

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

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:

43784371 46682
1 2 

result:

ok good plan

Test #4:

score: 0
Accepted
time: 18ms
memory: 66576kb

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:

24163289 54231
2 1 

result:

ok good plan

Test #5:

score: 0
Accepted
time: 4ms
memory: 66772kb

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:

2238283 30059
2 1 

result:

ok good plan

Test #6:

score: 0
Accepted
time: 8ms
memory: 66484kb

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:

49726384 82693
1 2 

result:

ok good plan

Test #7:

score: 0
Accepted
time: 8ms
memory: 66576kb

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: 15ms
memory: 66580kb

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:

808168 2955
1 2 

result:

ok good plan

Test #9:

score: 0
Accepted
time: 12ms
memory: 66596kb

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:

2154151 10958
1 2 

result:

ok good plan

Test #10:

score: 0
Accepted
time: 8ms
memory: 66644kb

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:

226217 248
1 2 

result:

ok good plan

Test #11:

score: 0
Accepted
time: 18ms
memory: 66528kb

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:

475741 470
1 2 

result:

ok good plan

Test #12:

score: 0
Accepted
time: 4ms
memory: 66584kb

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:

17683 18
1 2 

result:

ok good plan

Test #13:

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

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:

2287141 2277
2 1 

result:

ok good plan

Test #14:

score: 0
Accepted
time: 3ms
memory: 66596kb

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:

288803 288
1 2 

result:

ok good plan

Subtask #2:

score: 24
Accepted

Test #15:

score: 24
Accepted
time: 10ms
memory: 66584kb

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:

2848 5
2 1 

result:

ok good plan

Test #16:

score: 0
Accepted
time: 4ms
memory: 66616kb

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:

1449 5
3559 6
8909 10
1 4 3 2 

result:

ok good plan

Test #17:

score: 0
Accepted
time: 7ms
memory: 66632kb

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:

2437 14
9640 27
1087 2
13079 18
54589 60
2 5 1 6 4 3 

result:

ok good plan

Test #18:

score: 0
Accepted
time: 12ms
memory: 66708kb

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
2031 4
4613 6
18353 18
61843 48
6 3 2 4 5 1 

result:

ok good plan

Test #19:

score: 0
Accepted
time: 4ms
memory: 66564kb

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:

1169 6
795 2
5537 9
8153 10
30631 30
6 1 4 2 3 5 

result:

ok good plan

Test #20:

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

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:

1131 4
9101 16
4331 5
1 4 3 2 

result:

ok good plan

Test #21:

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

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:

1868 3
2 1 

result:

ok good plan

Test #22:

score: 0
Accepted
time: 7ms
memory: 66540kb

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
1315 9
680 3
305 1
11759 30
6 1 4 3 2 5 

result:

ok good plan

Test #23:

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

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:

4246 15
5173 9
877 1
17783 15
1489 1
4 3 2 5 1 6 

result:

ok good plan

Test #24:

score: 0
Accepted
time: 4ms
memory: 66600kb

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:

1101 4
5021 9
1683 2
1118 1
8375 6
6 5 2 3 1 4 

result:

ok good plan

Test #25:

score: 0
Accepted
time: 7ms
memory: 66828kb

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
5432 15
552 1
6604 9
27377 30
4 3 5 6 2 1 

result:

ok good plan

Test #26:

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

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
57 2
145 3
1 4 2 3 

result:

ok good plan

Test #27:

score: 0
Accepted
time: 7ms
memory: 66620kb

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:

1341 4
6747 10
8193 8
1 2 3 4 

result:

ok good plan

Test #28:

score: 0
Accepted
time: 3ms
memory: 66672kb

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
1690 3
1697 2
17027 15
42731 30
6 3 1 4 5 2 

result:

ok good plan

Test #29:

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

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:

933 4
6989 15
2189 3
8695 9
36293 30
2 4 6 5 1 3 

result:

ok good plan

Test #30:

score: 0
Accepted
time: 12ms
memory: 66644kb

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:

1775 6
1790 3
8959 10
14471 12
9001 6
4 3 5 2 6 1 

result:

ok good plan

Test #31:

score: 0
Accepted
time: 4ms
memory: 66664kb

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:

3878 15
6413 12
3237 4
3235 3
16195 12
3 5 2 1 6 4 

result:

ok good plan

Test #32:

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

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:

953 3
3911 6
988 1
3964 3
4970 3
1 2 3 4 5 6 

result:

ok good plan

Test #33:

score: 0
Accepted
time: 22ms
memory: 66668kb

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:

1000 3
2000 3
1000 1
4000 3
5000 3
1 2 3 4 5 6 

result:

ok good plan

Test #34:

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

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:

1962 5
3962 5
5906 5
7904 5
5 1 2 3 4 

result:

ok good plan

Test #35:

score: 0
Accepted
time: 8ms
memory: 66600kb

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:

3923 12
3971 6
1983 2
20057 15
19987 12
1 2 3 4 5 6 

result:

ok good plan

Test #36:

score: 0
Accepted
time: 8ms
memory: 66656kb

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:

1000 3
2000 3
1000 1
4000 3
4999 3
1 2 3 4 6 5 

result:

ok good plan

Test #37:

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

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:

5 2
5 1
2 1 3 

result:

ok good plan

Test #38:

score: 0
Accepted
time: 7ms
memory: 66616kb

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:

362 1
728 1
2191 2
1472 1
1 2 3 4 5 

result:

ok good plan

Test #39:

score: 0
Accepted
time: 13ms
memory: 66848kb

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
3417 4
10397 8
1 2 3 4 

result:

ok good plan

Test #40:

score: 0
Accepted
time: 7ms
memory: 66592kb

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:

1743 2
1 2 

result:

ok good plan

Test #41:

score: 0
Accepted
time: 26ms
memory: 66688kb

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:

1756 5
7057 10
5289 5
7104 5
1 2 3 4 5 

result:

ok good plan

Subtask #3:

score: 71
Accepted

Test #42:

score: 71
Accepted
time: 152ms
memory: 71064kb

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:

11174200 28005309
22418896 28026703
68854267 55673944
93215158 53267119
99917765 44916703
132106351 47920308
8740323 2677628
218158172 54890811
185721461 40219031
78655008 14886283
275185257 47523393
86733468 13285111
160597838 22559973
92570499 12022302
449162366 53959609
77444043 8587439
58180483 ...

result:

ok good plan

Test #43:

score: 0
Accepted
time: 1005ms
memory: 85448kb

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:

30623539 68263118
122140594 136130096
190049789 135653362
123769199 65822759
146095929 61846333
389791788 134620666
435296429 126945112
35691331 8385191
324957589 67959183
360129203 67822583
372733841 62851026
360330006 52006352
882701887 116471990
279513697 33258002
1213651591 136281722
659469599 6...

result:

ok good plan

Test #44:

score: 0
Accepted
time: 325ms
memory: 77384kb

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:

5600497 4049265
34870127 11431000
50078377 10283070
178686463 27499260
37538225 4222018
86738734 7799875
169867246 12733605
105695643 6437125
211287987 11395120
129954848 6327231
126985619 5540769
221420249 8848445
1877981239 68184420
570702014 19101615
137780007 4232092
292101713 8268040
2389622417...

result:

ok good plan

Test #45:

score: 0
Accepted
time: 26ms
memory: 68436kb

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:

2980849 328140
90617743 4666560
61983241 1985240
40064693 885555
24571193 441576
59027391 850280
458165011 5454780
22949912 226965
66701539 592056
283763 2280
88863083 640575
8175114 53575
355922497 2133504
36533845 203214
143593645 745208
3487381 16970
8718313 39224
219278737 931100
17364757 70440
...

result:

ok good plan

Test #46:

score: 0
Accepted
time: 537ms
memory: 81500kb

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
48306393 32395748
111361403 47997924
121275361 38058811
388654089 98142720
134787582 25816529
504197165 80023081
334580999 44367705
733224954 87360193
862923132 91821047
996021201 90555926
315136838 26362094
1036596857 77235293
1377000245 94336544
121110959 7637910
1473511662 87265...

result:

ok good plan

Test #47:

score: 0
Accepted
time: 1395ms
memory: 80768kb

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:

73893 22789714
831368 88277581
390033 26194772
3151604 146706090
4820715 179272462
2915472 90183439
7190449 186491110
1899704 42533241
8760915 172713462
426340 7540039
4338015 68573408
12623124 160221378
15491333 175621910
8085714 83027570
3486495 32911188
1101472 9640793
10584234 84756335
11725560 ...

result:

ok good plan

Test #48:

score: 0
Accepted
time: 292ms
memory: 74012kb

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:

515285 24603696
2766866 64805184
2914107 41153184
265028 2646288
9558085 76005216
188106 1237248
1181719 6442848
1337992 6062688
16822719 66439008
139250 490326
18989047 57119040
16513116 34807104
6429371 12023856
645554 1028916
1708125 2410176
3468592 4403808
4165969 4459968
31457826 24092352
37158...

result:

ok good plan

Test #49:

score: 0
Accepted
time: 1719ms
memory: 94552kb

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:

24319 1738495
468286 14835060
1553838 32750793
11869564 186566976
5065450 60693003
5008422 49905063
23584225 196835886
23458784 166807701
27513504 172890207
28561060 152931861
35670547 171593289
14773632 64897803
1305707 5234976
8667358 31534029
57726420 191496447
20374256 63349254
10657589 31159539...

result:

ok good plan

Test #50:

score: 0
Accepted
time: 565ms
memory: 83092kb

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:

1285421 34657962
6975818 93612238
12763587 92334746
3042596 15645630
20566745 80599742
24096882 77837400
5112821 13836718
15921448 36929522
4364163 8362050
21296810 35822918
18203515 27794308
18232716 24192114
18579899 20415906
144819240 97698962
155225511 101740880
161996428 97646862
77985091 45012...

result:

ok good plan

Test #51:

score: 0
Accepted
time: 1308ms
memory: 93460kb

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:

143869 5707166
8778862 171182880
7079727 83902552
17281836 149002208
20493305 140755504
25314642 143400544
16935751 81957720
1556008 6442256
258975 928974
42499170 130615328
91861 253376
23557596 58364648
18792709 42445188
61037718 127787104
8994975 17561268
17322064 31490956
3837325 6473286
715914 ...

result:

ok good plan

Test #52:

score: 0
Accepted
time: 1319ms
memory: 91216kb

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
2228742 39806813
13366100 167830808
14973145 148762876
5118678 41414612
7901509 54507712
26123128 156684412
30345795 159562368
30031330 141301072
34827485 147777736
45805476 167131948
46183163 154700660
51782458 158275792
16843785 46732684
57203024 147841728
14116...

result:

ok good plan

Test #53:

score: 0
Accepted
time: 3ms
memory: 66616kb

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
25708145 30723
4 3 2 1 

result:

ok good plan

Test #54:

score: 0
Accepted
time: 607ms
memory: 73424kb

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:

125 1872
142 702
2517 7020
764 1404
3595 4212
253 234
3455 2808
11084 7020
389 156
19618 7020
4393 1404
896 260
21983 5616
2470 540
11697 2106
10693 1755
46663 7020
95 13
15619 1872
24532 2808
13071 1404
41906 4212
36763 3510
3896 351
40219 3510
17498 1404
1425 104
5159 351
7495 468
58704 3510
3503 ...

result:

ok good plan

Test #55:

score: 0
Accepted
time: 708ms
memory: 86896kb

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:

2678 3235
1279 647
9882 3235
13569 2588
3985 647
26619 3235
59723 6470
7178 647
39997 3235
46726 3235
43119 2588
12350 647
64963 3235
72957 3235
154533 6470
16952 647
108887 3882
38957 1294
20883 647
43679 1294
93371 2588
49321 1294
265739 6470
82859 1941
172003 3882
121131 2588
128671 2588
34447 64...

result:

ok good plan

Test #56:

score: 0
Accepted
time: 574ms
memory: 84536kb

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:

1411 2010
4549 2412
17871 6030
2689 603
33067 6030
2383 335
13099 1608
3661 402
7003 670
23108 1809
17477 1206
12919 804
104431 6030
7535 402
2897 134
71164 3015
10939 402
7709 268
62099 2010
98984 3015
14441 402
112901 3015
119246 3015
8338 201
27077 603
111863 2412
9739 201
3384 67
52058 1005
5447...

result:

ok good plan

Test #57:

score: 0
Accepted
time: 1046ms
memory: 88812kb

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:

1327 2835
1733 1701
231 135
1453 567
3973 1134
272 63
1217 243
47357 8505
5435 756
65696 8505
24224 2835
82776 8505
91499 8505
5509 486
34472 2835
22139 1701
16426 1215
126774 8505
27778 1701
725 42
159411 8505
166982 8505
15560 729
1412 63
82483 3402
8075 324
5074 189
15806 567
154531 5103
29383 94...

result:

ok good plan

Test #58:

score: 0
Accepted
time: 581ms
memory: 84092kb

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
6103 2234
14945 3351
38433 5585
48961 5585
33613 3351
13614 1117
86908 5585
20077 1117
21677 1117
131399 5585
28736 1117
123225 4468
136283 4468
39641 1117
210351 5585
223222 5585
195145 4468
152975 3351
107867 2234
58736 1117
65740 1117
70779 1117
148201 2234
309961 4468
81008 1117
343679...

result:

ok good plan

Test #59:

score: 0
Accepted
time: 1658ms
memory: 98000kb

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:

29753 19250
46628 17875
40753 11750
98881 23250
228265 46500
7472 1375
32661 5500
11717 1750
118259 16000
25128 3125
45533 5000
154009 14750
646539 59000
112073 8875
36903 2750
166387 11000
696051 44000
167527 9625
712057 38500
56128 2925
1153063 58500
248033 11750
40357 1750
324643 13500
1329075 54...

result:

ok good plan

Test #60:

score: 0
Accepted
time: 1779ms
memory: 97956kb

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:

52831 81918
38845 26973
71701 32079
267934 96237
120922 34965
5881 1221
379141 65934
613124 83583
665955 83583
302203 30969
654734 60939
176470 14541
417739 30969
482371 31302
189853 11100
1191949 66600
1502522 80919
123607 6401
1112014 54945
759251 35631
102472 4551
1443334 61605
2487173 102897
254...

result:

ok good plan

Test #61:

score: 0
Accepted
time: 1973ms
memory: 97884kb

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:

207349 342796
458621 350768
1750547 807165
3164123 1076220
1313236 352761
1082661 237167
550912 89685
5608157 811151
2430160 320873
50107 5979
612419 59790
3269444 298950
4075694 324859
11653397 854997
22583317 1576463
1035874 69755
23172493 1432967
2681341 157447
25681141 1446918
5230719 271048
123...

result:

ok good plan

Test #62:

score: 0
Accepted
time: 1953ms
memory: 98136kb

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:

29194 13993
48393 13993
147552 33983
166751 33983
65315 11994
215144 35982
174373 25987
151593 19990
72841 7996
21500 1999
367111 31984
24822 1999
137787 9995
192877 11994
597830 35982
413131 23988
180456 9995
38731 1999
41461 1999
1025831 45977
784988 33983
804187 33983
247674 9995
8451889 325837
1...

result:

ok good plan

Test #63:

score: 0
Accepted
time: 1660ms
memory: 97968kb

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:

89693 46000
108493 39800
275879 79200
44893 8300
72893 10800
282279 37000
346651 35200
123593 10850
775237 64000
7837 600
894223 63200
147079 9700
1422809 87200
364051 21400
228199 12480
20667 1075
198781 9600
975737 45100
1391367 62000
133753 5760
2735153 115200
624823 25400
1504539 56800
146979 53...

result:

ok good plan

Test #64:

score: 0
Accepted
time: 1779ms
memory: 97912kb

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
45273 1999
267753 7996
91250 1999
338309 5997
1718688 25987
754692 9995
354611 3998
407457 3998
232840 1999
1041731 7996
871112 5997
620533 3998
329525 1999
2794037 15992
1831814 9995
388481 1999
415453 1999
1742437 7996
2296764 9995
2414001 9995
2025491 7996
529685 1999
3843173 13993
5...

result:

ok good plan

Test #65:

score: 0
Accepted
time: 1677ms
memory: 97988kb

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:

277020799 19786000
831210794 59358000
831359191 59358000
831507588 59358000
831655985 59358000
831804382 59358000
831952779 59358000
832101176 59358000
832249573 59358000
832397970 59358000
832546367 59358000
832694764 59358000
832843161 59358000
832991558 59358000
833139955 59358000
833288352 59358...

result:

ok good plan

Test #66:

score: 0
Accepted
time: 1376ms
memory: 97880kb

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:

2109 500
8327 1000
6481 500
14327 875
16227 800
17981 750
55289 2000
19779 625
86943 2500
9677 250
88597 2000
65587 1375
156751 3000
69539 1250
29881 500
7933 125
134559 2000
36193 500
189713 2500
22006 275
84367 1000
43449 500
226521 2500
83462 875
15847 160
101501 1000
261829 2500
13457 125
332983...

result:

ok good plan

Test #67:

score: 0
Accepted
time: 806ms
memory: 84856kb

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:

6167 8983
2499 1382
20574 7601
16480 4837
3195 691
50822 8983
69427 11056
75594 11056
5094 691
92765 11747
71983 7601
133430 13129
139597 13129
16547 1382
8905 691
140132 10365
136625 9674
142792 9674
33760 2073
107447 6219
12647 691
172988 8983
179155 8983
157682 7601
30079 1382
308907 13820
315074...

result:

ok good plan

Test #68:

score: 0
Accepted
time: 712ms
memory: 86224kb

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:

20936 18585
49306 23541
67764 23541
70115 17346
125743 24780
144201 24780
12061 1593
197224 23541
31007 3304
198209 18585
195604 16107
108937 8260
345269 24780
18862 1239
29249 1652
215809 11151
125918 6195
127681 5782
202022 8673
517840 21063
12263 472
565907 21063
174256 6195
137339 4543
272851 86...

result:

ok good plan

Test #69:

score: 0
Accepted
time: 1053ms
memory: 87524kb

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:

2135 1574
39770 20462
58081 23610
70096 23610
127757 25184
139772 25184
151787 25184
163802 25184
175817 25184
110443 14953
232901 29906
64377 7870
269523 31480
281538 31480
166059 17314
136257 13379
284529 26758
104200 8657
220415 17314
93916 7083
387679 28332
221883 15740
455781 31480
467796 31480...

result:

ok good plan

Test #70:

score: 0
Accepted
time: 1172ms
memory: 91524kb

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:

10699 7945
5000 1589
121081 28602
141314 28602
53849 9534
95974 14301
1903 227
104660 11123
16941 1589
91808 7945
295657 23835
253919 19068
429874 30191
450107 30191
182733 11123
385699 22246
434534 23835
152857 7945
97705 4767
457097 20657
31643 1362
116561 4767
401799 15890
172559 6356
188025 6356...

result:

ok good plan

Extra Test:

score: 0
Extra Test Passed