QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#812254#64. Naanguleng2007#29 123ms71544kbC++231.5kb2024-12-13 13:26:542024-12-13 13:27:00

Judging History

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

  • [2024-12-13 13:27:00]
  • 评测
  • 测评结果:29
  • 用时:123ms
  • 内存:71544kb
  • [2024-12-13 13:26:54]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define int long long

const int N=2005;

int a[N][N];

struct fraction
{
	int a,b;

	fraction operator +(const fraction& oth) const
	{
		return (fraction){a*oth.b+b*oth.a,b*oth.b};
	}

	fraction operator -(const fraction& oth) const
	{
		return (fraction){a*oth.b-b*oth.a,b*oth.b};
	}

	fraction operator *(const fraction& oth) const
	{
		return (fraction){a*oth.a,b*oth.b};
	}

	fraction operator /(const fraction& oth) const
	{
		return (fraction){a*oth.b,b*oth.a};
	}

	bool operator <=(const fraction& oth) const
	{
		return a*oth.b<=b*oth.a;
	}
};

fraction p[N][N];
bool vis[N];
int ans[N];

signed main()
{
	int n,l;
	cin >> n >> l;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=l;j++)
			scanf("%lld",&a[i][j]);

	for(int i=1;i<=n;i++)
	{
		int sum=0;
		for(int j=1;j<=l;j++)
			sum += a[i][j];

		int pos=0, tot=0;
		for(int k=1;k<n;k++)
		{
			while((fraction){tot+a[i][pos+1],1}<=(fraction){sum*k,n})
				tot += a[i][pos+1], pos++;

			p[i][k]=((fraction){sum*k,n}-(fraction){tot,1})/(fraction){a[i][pos+1],1}+(fraction){pos,1};
		}
	}

	for(int i=1;i<=n;i++)
	{
		int best=0;
		for(int j=1;j<=n;j++)
			if(!vis[j] && (!best || p[j][i]<=p[best][i]))
				best=j;
		
		ans[i]=best, vis[best]=true;
	}

	for(int i=1;i<n;i++)
	{
		p[ans[i]][i].a *= 2, p[ans[i]][i].b *= 2;
		printf("%lld %lld\n",p[ans[i]][i].a,p[ans[i]][i].b);
	}

	for(int i=1;i<=n;i++)
		printf("%lld ",ans[i]);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 5
Accepted

Test #1:

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

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:

237068176 316152
2 1 

result:

ok good plan

Test #2:

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

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:

184212432 217792
1 2 

result:

ok good plan

Test #3:

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

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:

262706226 280092
1 2 

result:

ok good plan

Test #4:

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

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:

96653156 216924
2 1 

result:

ok good plan

Test #5:

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

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:

8953132 120236
2 1 

result:

ok good plan

Test #6:

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

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:

198905536 330772
1 2 

result:

ok good plan

Test #7:

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

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:

16347802 279292
1 2 

result:

ok good plan

Test #8:

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

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:

48490080 177300
1 2 

result:

ok good plan

Test #9:

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

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:

21541510 109580
1 2 

result:

ok good plan

Test #10:

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

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:

111751198 122512
2 1 

result:

ok good plan

Test #11:

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

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:

83730416 82720
2 1 

result:

ok good plan

Test #12:

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

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:

43853840 44640
2 1 

result:

ok good plan

Test #13:

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

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:

9148564 9108
2 1 

result:

ok good plan

Test #14:

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

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:

52562146 52416
2 1 

result:

ok good plan

Subtask #2:

score: 24
Accepted

Test #15:

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

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:

11392 20
2 1 

result:

ok good plan

Test #16:

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

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:

11592 40
42708 72
35636 40
1 4 3 2 

result:

ok good plan

Test #17:

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

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:

14622 84
38560 108
19566 36
52316 72
109178 120
2 5 1 6 4 3 

result:

ok good plan

Test #18:

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

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:

29974 120
24372 48
83034 108
73412 72
123686 96
6 3 2 4 5 1 

result:

ok good plan

Test #19:

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

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:

4676 24
38160 96
66444 108
97836 120
122524 120
6 1 4 2 3 5 

result:

ok good plan

Test #20:

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

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:

4524 16
36404 64
34648 40
1 4 3 2 

result:

ok good plan

Test #21:

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

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:

7472 12
2 1 

result:

ok good plan

Test #22:

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

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:

2602 36
5260 36
8160 36
7320 24
23518 60
6 1 4 3 2 5 

result:

ok good plan

Test #23:

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

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:

16984 60
20692 36
10524 12
71132 60
17868 12
4 3 2 5 1 6 

result:

ok good plan

Test #24:

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

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:

6606 24
20084 36
20196 24
53664 48
67000 48
6 5 2 3 1 4 

result:

ok good plan

Test #25:

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

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:

10238 60
21728 60
33120 60
26416 36
54754 60
4 3 5 6 2 1 

result:

ok good plan

Test #26:

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

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:

578 40
912 32
1160 24
1 4 2 3 

result:

ok good plan

Test #27:

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

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:

8046 24
26988 40
16386 16
1 2 3 4 

result:

ok good plan

Test #28:

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

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:

17006 60
13520 24
10182 12
68108 60
85462 60
6 3 1 4 5 2 

result:

ok good plan

Test #29:

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

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:

11196 48
27956 60
26268 36
34780 36
72586 60
2 4 6 5 1 3 

result:

ok good plan

Test #30:

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

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:

14200 48
7160 12
53754 60
57884 48
72008 48
4 3 5 2 6 1 

result:

ok good plan

Test #31:

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

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:

15512 60
25652 48
38844 48
38820 36
64780 48
3 5 2 1 6 4 

result:

ok good plan

Test #32:

score: 24
Accepted
time: 2ms
memory: 8068kb

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:

30496 96
78220 120
59280 60
31712 24
19880 12
6 5 4 3 2 1 

result:

ok good plan

Test #33:

score: 24
Accepted
time: 2ms
memory: 8012kb

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:

36000 108
8000 12
12000 12
96000 72
20000 12
6 5 4 3 2 1 

result:

ok good plan

Test #34:

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

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:

7848 20
63392 80
35436 30
126464 80
5 4 3 2 1 

result:

ok good plan

Test #35:

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

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:

39230 120
63536 96
23796 24
144416 108
199870 120
6 5 4 3 2 1 

result:

ok good plan

Test #36:

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

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:

8000 24
56000 84
72000 72
32000 24
200004 120
6 5 4 3 1 2 

result:

ok good plan

Test #37:

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

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:

60 24
30 6
3 1 2 

result:

ok good plan

Test #38:

score: 24
Accepted
time: 2ms
memory: 8068kb

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:

14480 40
7280 10
43820 40
147200 100
5 4 3 2 1 

result:

ok good plan

Test #39:

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

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:

6854 16
13668 16
103970 80
4 3 2 1 

result:

ok good plan

Test #40:

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

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:

13944 16
2 1 

result:

ok good plan

Test #41:

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

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:

14048 40
28228 40
42312 40
71040 50
5 4 3 2 1 

result:

ok good plan

Subtask #3:

score: 0
Wrong Answer

Test #42:

score: 71
Accepted
time: 11ms
memory: 32736kb

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:

44696800 112021236
89675584 112106812
137708534 111347888
186430316 106534238
199835530 89833406
264212702 95840616
367093566 112460376
436316344 109781622
371442922 80438062
471930048 89317698
550370514 95046786
520400808 79710666
321195676 45119946
740563992 96178416
898324732 107919218
774440430 ...

result:

ok good plan

Test #43:

score: 0
Wrong Answer
time: 123ms
memory: 71544kb

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:

122494156 273052472
244281188 272260192
380099578 271306724
495076796 263291036
584383716 247385332
779583576 269241332
870592858 253890224
713826620 167703820
1299830356 271836732
1440516812 271290332
1490935364 251404104
1441320024 208025408
1765403774 232943980
2236109576 266064016
2427303182 272...

result:

wrong answer