QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#461432#6339. CookiesRafi22#63 376ms637660kbC++202.3kb2024-07-02 18:57:332024-07-02 18:57:33

Judging History

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

  • [2024-07-02 18:57:33]
  • 评测
  • 测评结果:63
  • 用时:376ms
  • 内存:637660kb
  • [2024-07-02 18:57:33]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

#ifdef DEBUG
auto&operator<<(auto&o,pair<auto,auto>p){return o<<"("<<p.first<<", "<<p.second<<")";}
auto operator<<(auto&o,auto x)->decltype(x.end(),o){o<<"{";int i=0;for(auto e:x)o<<","+!i++<<e;return o<<"}";}
#define debug(X...)cerr<<"["#X"]: ",[](auto...$){((cerr<<$<<"; "),...)<<endl;}(X)
#else
#define debug(...){}
#endif


#define ll long long
#define pb push_back
#define st first
#define nd second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
#define FOR(i,l,r) for(int i=(l);i<=(r);i++)
#define ROF(i,r,l) for(int i=(r);i>=(l);i--)
#define endl '\n'
int inf=1000000007;
ll infl=1000000000000000007;
ll mod=998244353;

const int N=507;

int ord[N];
int a[N];
bool is[N];
int DP[N][N][N];
int zkad[N][N][N];

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n,m,s=0;
	cin>>n;
	vector<int>T;
	FOR(i,1,n) 
	{
		cin>>a[i];
		s+=a[i];
		T.pb(a[i]);
	}
	sort(all(T),greater<int>());
	cin>>m;
	FOR(i,1,m)
	{
		int x;
		cin>>x;
		is[x]=1;
	}
	FOR(i,0,n) FOR(j,0,s) FOR(l,0,s) DP[i][j][l]=inf;
	DP[1][0][0]=0;
	int ss=0;
	FOR(i,1,n)
	{
		ss+=T[i-1];
		FOR(j,0,s)
		{
			FOR(l,0,s)
			{
				if(is[i]&&j>=i&&l>0&&DP[i][j-i][l-1]<DP[i][j][l])
				{
					DP[i][j][l]=DP[i][j-i][l-1];
					zkad[i][j][l]=i;
				}
			}
		}
		FOR(j,0,s)
		{
			FOR(l,0,s)
			{
				if(DP[i][j][l]!=inf) debug(i,j,l,DP[i][j][l]);
				int t=max(0,(ss-j+i-1)/i);
				DP[i][j][l]=max(DP[i][j][l],t+l);
				if(DP[i][j][l]!=inf)
				{
					debug(ss,t);
					debug(i,j,l,DP[i][j][l]);
				}
				if(i==n&&j==s&&l>=DP[i][j][l])
				{
					cout<<l<<endl;
					vector<int>V;
					int x=s,y=l;
					debug(x);
					ROF(k,n,1)
					{
						while(zkad[k][x][y]==k)
						{
							x-=k;
							y--;
							V.pb(k);
						}
					}
					debug(x);
					reverse(all(V));
					vector<pair<int,int>>X;
					FOR(k,1,n)
					{
						X.pb({a[k],k});
						debug(a[k]);
					}
					for(auto x:V) 
					{
						cout<<x<<" ";
						sort(all(X),greater<pair<int,int>>());
						for(int j=0;j<x;j++) 
						{
							cout<<X[j].nd<<" ";
							X[j].st--;
						}
						cout<<endl;
					}
					return 0;
				}
				DP[i+1][j][l]=DP[i][j][l];
			}
		}
	}
	cout<<-1;
	return 0;
}


Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 6
Accepted

Test #1:

score: 6
Accepted
time: 1ms
memory: 7640kb

input:

1
1
1
1

output:

1
1 1 

result:

ok good!

Test #2:

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

input:

2
1 1
1
1

output:

2
1 2 
1 1 

result:

ok good!

Test #3:

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

input:

2
1 1
1
2

output:

1
2 2 1 

result:

ok good!

Test #4:

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

input:

2
1 1
2
1 2

output:

1
2 2 1 

result:

ok good!

Test #5:

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

input:

4
1 1 1 1
2
2 3

output:

2
2 4 3 
2 2 1 

result:

ok good!

Test #6:

score: 0
Accepted
time: 2ms
memory: 19964kb

input:

8
1 1 1 1 1 1 1 1
3
1 4 5

output:

2
4 8 7 6 5 
4 4 3 2 1 

result:

ok good!

Test #7:

score: 0
Accepted
time: 216ms
memory: 508216kb

input:

500
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

500
1 500 
1 499 
1 498 
1 497 
1 496 
1 495 
1 494 
1 493 
1 492 
1 491 
1 490 
1 489 
1 488 
1 487 
1 486 
1 485 
1 484 
1 483 
1 482 
1 481 
1 480 
1 479 
1 478 
1 477 
1 476 
1 475 
1 474 
1 473 
1 472 
1 471 
1 470 
1 469 
1 468 
1 467 
1 466 
1 465 
1 464 
1 463 
1 462 
1 461 
1 460 
1 459 
1 ...

result:

ok good!

Test #8:

score: 0
Accepted
time: 228ms
memory: 509768kb

input:

500
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

1
500 500 499 498 497 496 495 494 493 492 491 490 489 488 487 486 485 484 483 482 481 480 479 478 477 476 475 474 473 472 471 470 469 468 467 466 465 464 463 462 461 460 459 458 457 456 455 454 453 452 451 450 449 448 447 446 445 444 443 442 441 440 439 438 437 436 435 434 433 432 431 430 429 428 42...

result:

ok good!

Test #9:

score: 0
Accepted
time: 259ms
memory: 637660kb

input:

500
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

2
250 500 499 498 497 496 495 494 493 492 491 490 489 488 487 486 485 484 483 482 481 480 479 478 477 476 475 474 473 472 471 470 469 468 467 466 465 464 463 462 461 460 459 458 457 456 455 454 453 452 451 450 449 448 447 446 445 444 443 442 441 440 439 438 437 436 435 434 433 432 431 430 429 428 42...

result:

ok good!

Test #10:

score: 0
Accepted
time: 233ms
memory: 508424kb

input:

500
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

-1

result:

ok no solution

Test #11:

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

input:

500
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

11
43 500 499 498 497 496 495 494 493 492 491 490 489 488 487 486 485 484 483 482 481 480 479 478 477 476 475 474 473 472 471 470 469 468 467 466 465 464 463 462 461 460 459 458 
43 457 456 455 454 453 452 451 450 449 448 447 446 445 444 443 442 441 440 439 438 437 436 435 434 433 432 431 430 429 42...

result:

ok good!

Test #12:

score: 0
Accepted
time: 221ms
memory: 539088kb

input:

500
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

250
2 500 499 
2 498 497 
2 496 495 
2 494 493 
2 492 491 
2 490 489 
2 488 487 
2 486 485 
2 484 483 
2 482 481 
2 480 479 
2 478 477 
2 476 475 
2 474 473 
2 472 471 
2 470 469 
2 468 467 
2 466 465 
2 464 463 
2 462 461 
2 460 459 
2 458 457 
2 456 455 
2 454 453 
2 452 451 
2 450 449 
2 448 447 ...

result:

ok good!

Test #13:

score: 0
Accepted
time: 236ms
memory: 499116kb

input:

484
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

22
22 484 483 482 481 480 479 478 477 476 475 474 473 472 471 470 469 468 467 466 465 464 463 
22 462 461 460 459 458 457 456 455 454 453 452 451 450 449 448 447 446 445 444 443 442 441 
22 440 439 438 437 436 435 434 433 432 431 430 429 428 427 426 425 424 423 422 421 420 419 
22 418 417 416 415 41...

result:

ok good!

Test #14:

score: 0
Accepted
time: 263ms
memory: 514956kb

input:

495
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

55
9 495 494 493 492 491 490 489 488 487 
9 486 485 484 483 482 481 480 479 478 
9 477 476 475 474 473 472 471 470 469 
9 468 467 466 465 464 463 462 461 460 
9 459 458 457 456 455 454 453 452 451 
9 450 449 448 447 446 445 444 443 442 
9 441 440 439 438 437 436 435 434 433 
9 432 431 430 429 428 42...

result:

ok good!

Test #15:

score: 0
Accepted
time: 248ms
memory: 515248kb

input:

500
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

4
125 500 499 498 497 496 495 494 493 492 491 490 489 488 487 486 485 484 483 482 481 480 479 478 477 476 475 474 473 472 471 470 469 468 467 466 465 464 463 462 461 460 459 458 457 456 455 454 453 452 451 450 449 448 447 446 445 444 443 442 441 440 439 438 437 436 435 434 433 432 431 430 429 428 42...

result:

ok good!

Test #16:

score: 0
Accepted
time: 186ms
memory: 509104kb

input:

499
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

27
5 499 498 497 496 495 
5 494 493 492 491 490 
5 489 488 487 486 485 
5 484 483 482 481 480 
17 479 478 477 476 475 474 473 472 471 470 469 468 467 466 465 464 463 
21 462 461 460 459 458 457 456 455 454 453 452 451 450 449 448 447 446 445 444 443 442 
21 441 440 439 438 437 436 435 434 433 432 43...

result:

ok good!

Test #17:

score: 0
Accepted
time: 204ms
memory: 512360kb

input:

499
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

19
17 499 498 497 496 495 494 493 492 491 490 489 488 487 486 485 484 483 
23 482 481 480 479 478 477 476 475 474 473 472 471 470 469 468 467 466 465 464 463 462 461 460 
27 459 458 457 456 455 454 453 452 451 450 449 448 447 446 445 444 443 442 441 440 439 438 437 436 435 434 433 
27 432 431 430 42...

result:

ok good!

Test #18:

score: 0
Accepted
time: 229ms
memory: 509040kb

input:

499
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

7
18 499 498 497 496 495 494 493 492 491 490 489 488 487 486 485 484 483 482 
64 481 480 479 478 477 476 475 474 473 472 471 470 469 468 467 466 465 464 463 462 461 460 459 458 457 456 455 454 453 452 451 450 449 448 447 446 445 444 443 442 441 440 439 438 437 436 435 434 433 432 431 430 429 428 427...

result:

ok good!

Test #19:

score: 0
Accepted
time: 229ms
memory: 505652kb

input:

499
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

4
56 499 498 497 496 495 494 493 492 491 490 489 488 487 486 485 484 483 482 481 480 479 478 477 476 475 474 473 472 471 470 469 468 467 466 465 464 463 462 461 460 459 458 457 456 455 454 453 452 451 450 449 448 447 446 445 444 
56 443 442 441 440 439 438 437 436 435 434 433 432 431 430 429 428 427...

result:

ok good!

Test #20:

score: 0
Accepted
time: 233ms
memory: 532896kb

input:

499
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

2
213 499 498 497 496 495 494 493 492 491 490 489 488 487 486 485 484 483 482 481 480 479 478 477 476 475 474 473 472 471 470 469 468 467 466 465 464 463 462 461 460 459 458 457 456 455 454 453 452 451 450 449 448 447 446 445 444 443 442 441 440 439 438 437 436 435 434 433 432 431 430 429 428 427 42...

result:

ok good!

Test #21:

score: 0
Accepted
time: 238ms
memory: 569144kb

input:

499
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

-1

result:

ok no solution

Test #22:

score: 0
Accepted
time: 228ms
memory: 567216kb

input:

499
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

-1

result:

ok no solution

Test #23:

score: 0
Accepted
time: 225ms
memory: 508236kb

input:

493
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

17
1 493 
1 492 
1 491 
1 490 
1 489 
1 488 
1 487 
1 486 
1 485 
1 484 
1 483 
18 482 481 480 479 478 477 476 475 474 473 472 471 470 469 468 467 466 465 
18 464 463 462 461 460 459 458 457 456 455 454 453 452 451 450 449 448 447 
35 446 445 444 443 442 441 440 439 438 437 436 435 434 433 432 431 4...

result:

ok good!

Test #24:

score: 0
Accepted
time: 186ms
memory: 506376kb

input:

493
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

17
1 493 
1 492 
1 491 
1 490 
1 489 
1 488 
1 487 
1 486 
1 485 
1 484 
18 483 482 481 480 479 478 477 476 475 474 473 472 471 470 469 468 467 466 
18 465 464 463 462 461 460 459 458 457 456 455 454 453 452 451 450 449 448 
18 447 446 445 444 443 442 441 440 439 438 437 436 435 434 433 432 431 430 ...

result:

ok good!

Test #25:

score: 0
Accepted
time: 184ms
memory: 505288kb

input:

493
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

17
16 493 492 491 490 489 488 487 486 485 484 483 482 481 480 479 478 
16 477 476 475 474 473 472 471 470 469 468 467 466 465 464 463 462 
16 461 460 459 458 457 456 455 454 453 452 451 450 449 448 447 446 
16 445 444 443 442 441 440 439 438 437 436 435 434 433 432 431 430 
16 429 428 427 426 425 42...

result:

ok good!

Test #26:

score: 0
Accepted
time: 199ms
memory: 505108kb

input:

493
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

17
16 493 492 491 490 489 488 487 486 485 484 483 482 481 480 479 478 
16 477 476 475 474 473 472 471 470 469 468 467 466 465 464 463 462 
16 461 460 459 458 457 456 455 454 453 452 451 450 449 448 447 446 
16 445 444 443 442 441 440 439 438 437 436 435 434 433 432 431 430 
16 429 428 427 426 425 42...

result:

ok good!

Test #27:

score: 0
Accepted
time: 242ms
memory: 508596kb

input:

493
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

17
16 493 492 491 490 489 488 487 486 485 484 483 482 481 480 479 478 
16 477 476 475 474 473 472 471 470 469 468 467 466 465 464 463 462 
16 461 460 459 458 457 456 455 454 453 452 451 450 449 448 447 446 
16 445 444 443 442 441 440 439 438 437 436 435 434 433 432 431 430 
16 429 428 427 426 425 42...

result:

ok good!

Subtask #2:

score: 0
Wrong Answer

Test #28:

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

input:

1
15
1
1

output:

15
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 

result:

ok good!

Test #29:

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

input:

1
500
1
1

output:

500
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1...

result:

ok good!

Test #30:

score: -7
Wrong Answer
time: 24ms
memory: 22048kb

input:

1
3000
1
1

output:

-1

result:

wrong answer you didn't find a solution but jury did

Subtask #3:

score: 12
Accepted

Test #45:

score: 12
Accepted
time: 1ms
memory: 12108kb

input:

2
7 8
2
1 2

output:

8
1 2 
2 2 1 
2 2 1 
2 2 1 
2 2 1 
2 2 1 
2 2 1 
2 2 1 

result:

ok good!

Test #46:

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

input:

3
5 4 6
2
2 3

output:

6
2 3 1 
2 3 2 
2 3 1 
3 3 2 1 
3 3 2 1 
3 3 2 1 

result:

ok good!

Test #47:

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

input:

3
4 2 9
3
1 2 3

output:

9
1 3 
1 3 
1 3 
2 3 1 
2 3 1 
2 3 2 
2 3 1 
2 3 2 
2 3 1 

result:

ok good!

Test #48:

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

input:

4
3 5 4 3
2
3 4

output:

5
3 2 3 4 
3 2 3 1 
3 2 4 3 
3 2 1 4 
3 3 2 1 

result:

ok good!

Test #49:

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

input:

4
1 4 5 5
3
1 3 4

output:

5
3 4 3 2 
3 4 3 2 
3 4 3 2 
3 4 3 2 
3 4 3 1 

result:

ok good!

Test #50:

score: 0
Accepted
time: 2ms
memory: 15948kb

input:

4
3 3 6 3
3
2 3 4

output:

6
2 3 4 
2 3 2 
2 3 1 
3 3 4 2 
3 3 1 4 
3 3 2 1 

result:

ok good!

Test #51:

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

input:

5
4 3 3 3 1
3
2 4 5

output:

4
2 1 4 
4 3 2 1 4 
4 3 2 1 5 
4 4 3 2 1 

result:

ok good!

Test #52:

score: 0
Accepted
time: 2ms
memory: 16172kb

input:

5
4 3 3 3 2
3
3 4 5

output:

4
3 1 4 3 
4 2 1 5 4 
4 3 2 1 5 
4 4 3 2 1 

result:

ok good!

Test #53:

score: 0
Accepted
time: 2ms
memory: 17916kb

input:

5
4 4 4 2 1
3
2 4 5

output:

5
2 3 2 
2 1 3 
2 2 1 
4 4 3 2 1 
5 5 4 3 2 1 

result:

ok good!

Test #54:

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

input:

5
3 3 3 3 3
3
1 2 4

output:

5
1 5 
2 4 3 
4 2 1 5 4 
4 3 2 1 5 
4 4 3 2 1 

result:

ok good!

Test #55:

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

input:

6
3 3 3 2 2 2
3
2 4 6

output:

-1

result:

ok no solution

Test #56:

score: 0
Accepted
time: 2ms
memory: 20032kb

input:

6
3 3 3 2 2 2
3
2 5 6

output:

3
5 3 2 1 6 5 
5 4 3 2 1 6 
5 5 4 3 2 1 

result:

ok good!

Test #57:

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

input:

6
4 4 3 2 1 1
3
1 3 5

output:

5
3 2 1 3 
3 2 1 4 
3 3 2 1 
3 6 5 4 
3 3 2 1 

result:

ok good!

Test #58:

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

input:

6
7 2 2 2 1 1
5
2 3 4 5 6

output:

7
2 1 4 
2 1 3 
2 1 2 
2 1 6 
2 1 5 
2 1 4 
3 3 2 1 

result:

ok good!

Test #59:

score: 0
Accepted
time: 2ms
memory: 19972kb

input:

7
3 3 3 2 2 1 1
3
1 4 6

output:

4
1 3 
4 2 1 5 4 
4 3 2 1 7 
6 6 5 4 3 2 1 

result:

ok good!

Test #60:

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

input:

7
4 4 3 1 1 1 1
3
1 4 6

output:

6
1 2 
1 1 
1 3 
4 2 1 3 7 
4 2 1 6 5 
4 4 3 2 1 

result:

ok good!

Test #61:

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

input:

8
2 2 2 2 2 2 2 1
6
1 2 3 4 6 7

output:

3
3 7 6 5 
6 4 3 2 1 8 7 
6 6 5 4 3 2 1 

result:

ok good!

Test #62:

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

input:

8
3 3 3 2 1 1 1 1
4
4 6 7 8

output:

3
4 3 2 1 4 
4 3 2 1 8 
7 7 6 5 4 3 2 1 

result:

ok good!

Test #63:

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

input:

8
4 3 3 1 1 1 1 1
4
1 6 7 8

output:

8
1 1 
1 3 
1 2 
1 1 
1 3 
1 2 
1 1 
8 8 7 6 5 4 3 2 1 

result:

ok good!

Test #64:

score: 0
Accepted
time: 2ms
memory: 22056kb

input:

9
4 3 2 1 1 1 1 1 1
4
3 4 5 7

output:

4
3 1 2 3 
4 1 2 9 8 
4 1 7 6 5 
4 4 3 2 1 

result:

ok good!

Test #65:

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

input:

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

output:

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

result:

ok good!

Test #66:

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

input:

14
2 1 1 1 1 1 1 1 1 1 1 1 1 1
14
1 2 3 4 5 6 7 8 9 10 11 12 13 14

output:

2
7 1 14 13 12 11 10 9 
8 8 7 6 5 4 3 2 1 

result:

ok good!

Test #67:

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

input:

4
2 2 2 1
2
1 4

output:

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

result:

ok good!

Subtask #4:

score: 45
Accepted

Dependency #1:

100%
Accepted

Dependency #3:

100%
Accepted

Test #68:

score: 45
Accepted
time: 70ms
memory: 202256kb

input:

150
24 12 11 10 9 9 9 9 9 8 8 7 7 7 7 7 6 6 6 6 6 6 6 5 5 5 5 5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

25
18 1 2 3 4 9 8 7 6 5 11 10 16 15 14 13 12 23 22 
18 1 2 3 4 9 8 7 6 5 11 10 21 20 19 18 17 16 15 
18 1 2 3 4 9 8 7 6 5 14 13 12 11 10 36 35 34 33 
18 1 2 3 4 9 8 7 6 5 32 31 30 29 28 27 26 25 24 
18 1 2 3 4 23 22 21 20 19 18 17 16 15 14 13 12 11 10 
18 1 2 3 9 8 7 6 5 4 49 48 47 46 45 44 43 42 41...

result:

ok good!

Test #69:

score: 0
Accepted
time: 95ms
memory: 245208kb

input:

200
9 9 9 8 8 8 7 7 6 6 6 6 6 6 6 6 5 5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

10
1 3 
9 2 1 6 5 4 3 8 7 16 
9 2 1 6 5 4 3 15 14 13 
9 2 1 12 11 10 9 8 7 6 
9 5 4 3 2 1 26 25 24 23 
78 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48...

result:

ok good!

Test #70:

score: 0
Accepted
time: 116ms
memory: 301212kb

input:

250
8 7 7 7 7 6 6 6 6 5 5 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

9
1 1 
1 5 
33 4 3 2 1 9 8 7 6 5 17 16 15 14 13 12 11 10 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 
33 4 3 2 1 9 8 7 6 5 17 16 15 14 13 12 11 10 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 
33 4 3 2 1 9 8 7 6 5 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 
33 4 3...

result:

ok good!

Test #71:

score: 0
Accepted
time: 155ms
memory: 331336kb

input:

300
8 6 6 5 5 5 5 4 4 4 4 4 4 4 4 4 4 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

9
22 1 3 2 7 6 5 4 17 16 15 14 13 12 11 10 9 8 46 45 44 43 42 
23 1 3 2 7 6 5 4 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 
23 1 3 2 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 
23 1 5 4 3 2 125 124 123 122 121 120 119 118 117 116 115 114 113 112 111 110 109 108 
23 1 107 106 105 10...

result:

ok good!

Test #72:

score: 0
Accepted
time: 132ms
memory: 339692kb

input:

300
5 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

6
6 7 6 5 4 3 2 
6 1 17 16 15 14 13 
63 12 11 10 9 8 7 6 5 4 3 2 1 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 134 133 132 131 130 129 128 127 126 125 124 123 122 121 120 119 118 117 116 115 114 
63 12 11 10 9 8 7 6 5 4 3 2 1 113 112 111 110 109 108 107 ...

result:

ok good!

Test #73:

score: 0
Accepted
time: 127ms
memory: 368360kb

input:

350
5 5 4 4 4 4 4 4 4 4 4 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

6
2 2 1 
2 11 10 
53 9 8 7 6 5 4 3 2 1 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 110 109 108 107 106 105 104 103 102 101 100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 
53 9 8 7 6 5 4 3 2 1 84 83 82 81 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 ...

result:

ok good!

Test #74:

score: 0
Accepted
time: 42ms
memory: 114524kb

input:

70
51 39 26 24 21 18 16 15 15 12 11 10 10 9 9 9 8 8 7 7 7 7 7 7 6 6 6 6 6 6 6 5 5 5 5 5 5 5 4 4 4 4 4 4 3 3 3 3 3 3 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1
14
1 14 15 17 26 27 34 35 41 44 48 58 62 65

output:

56
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 2 
1 1 
1 2 
1 1 
1 2 
1 1 
1 2 
1 1 
1 2 
1 1 
14 2 1 3 4 5 6 7 9 8 10 11 13 12 16 
14 2 1 3 4 5 6 7 9 8 10 11 15 14 13 
14 2 1 3 4 5 6 7 9 8 10 12 11 18 17 
14 2 1 3 4 5 6 7 9 8 10 16 15 14 13 
14 2 1 3 4 5 6 7 9 8 12 11 10 24 23 
14...

result:

ok good!

Test #75:

score: 0
Accepted
time: 35ms
memory: 102388kb

input:

70
22 22 20 19 18 15 14 13 13 13 12 12 12 12 12 12 11 11 10 9 9 9 9 9 9 9 8 8 8 8 8 7 6 6 6 6 6 5 5 5 5 5 5 5 4 4 3 3 3 3 3 3 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
9
1 3 7 9 16 17 62 68 69

output:

24
16 2 1 3 4 5 6 7 10 9 8 16 15 14 13 12 11 
16 2 1 3 4 5 6 7 10 9 8 18 17 16 15 14 13 
16 2 1 3 4 5 6 7 12 11 10 9 8 19 18 17 16 
16 2 1 3 4 5 6 7 15 14 13 12 11 10 9 8 26 
17 2 1 3 4 5 6 7 25 24 23 22 21 20 19 18 17 16 
17 2 1 3 4 5 6 15 14 13 12 11 10 9 8 7 31 30 
17 2 1 3 4 5 6 29 28 27 26 25 2...

result:

ok good!

Test #76:

score: 0
Accepted
time: 16ms
memory: 69976kb

input:

40
61 55 33 31 28 26 26 23 21 20 18 15 13 11 11 10 9 9 8 8 7 7 7 6 4 4 4 4 3 3 2 2 2 2 2 1 1 1 1 1
9
1 12 18 20 24 29 30 32 40

output:

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

result:

ok good!

Test #77:

score: 0
Accepted
time: 51ms
memory: 153096kb

input:

127
64 32 32 16 16 16 16 8 8 8 8 8 8 8 8 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
7
1 2 4 8 16 32 64

output:

64
4 1 3 2 7 
4 1 3 2 6 
4 1 3 2 5 
4 1 3 2 4 
4 1 3 2 7 
4 1 3 2 6 
4 1 3 2 5 
4 1 3 2 4 
4 1 3 2 7 
4 1 3 2 6 
4 1 3 2 5 
4 1 3 2 4 
4 1 3 2 7 
4 1 3 2 6 
4 1 3 2 5 
4 1 3 2 4 
8 1 3 2 7 6 5 4 15 
8 1 3 2 7 6 5 4 14 
8 1 3 2 7 6 5 4 13 
8 1 3 2 7 6 5 4 12 
8 1 3 2 11 10 9 8 7 
8 1 3 2 6 5 4 15 14 ...

result:

ok good!

Test #78:

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

input:

10
31 67 31 15 21 37 53 96 81 68
4
1 2 8 10

output:

115
2 8 9 
2 8 9 
2 8 9 
2 8 9 
2 8 9 
2 8 9 
2 8 9 
2 8 9 
2 8 9 
2 8 9 
2 8 9 
2 8 9 
2 8 9 
2 8 10 
2 8 9 
2 8 10 
2 8 9 
2 8 2 
2 8 10 
2 8 9 
2 8 2 
2 8 10 
2 8 9 
2 8 2 
2 8 10 
2 8 9 
2 8 2 
2 8 10 
2 8 9 
2 8 2 
2 8 10 
2 8 9 
2 8 2 
2 8 10 
2 8 9 
2 8 2 
2 10 9 
2 8 2 
2 10 9 
2 8 2 
2 10 9...

result:

ok good!

Test #79:

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

input:

40
24 20 23 12 7 11 20 16 1 4 2 21 12 13 7 17 5 15 4 24 17 8 13 8 15 9 16 21 12 7 3 16 6 5 21 8 11 12 11 23
5
8 12 13 27 29

output:

24
12 20 1 40 3 35 28 12 7 2 21 16 32 
12 20 1 40 3 35 28 12 7 2 27 21 16 
12 20 1 40 3 35 28 12 7 2 8 32 27 
12 20 1 40 3 35 28 12 7 2 25 21 18 
12 20 1 40 3 35 28 12 7 2 16 8 32 
12 20 1 40 3 35 28 12 7 2 27 25 21 
12 20 1 40 3 35 28 12 18 16 8 7 2 
12 20 1 40 3 35 28 12 32 27 25 23 21 
13 20 1 40...

result:

ok good!

Test #80:

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

input:

40
2 18 20 17 18 15 12 4 6 12 13 20 2 15 22 20 21 8 8 1 3 9 22 16 5 8 12 11 8 16 4 19 14 13 13 16 24 21 1 11
14
1 4 5 8 10 13 14 21 23 24 32 33 34 36

output:

24
13 37 23 15 38 17 16 12 3 32 5 2 4 36 
21 37 23 15 38 17 16 12 3 32 5 2 30 24 4 36 14 6 33 35 34 11 
21 37 23 15 38 17 16 12 3 32 5 2 30 24 4 36 14 6 33 35 34 27 
21 37 23 15 38 17 16 12 3 32 5 2 30 24 4 36 14 6 33 11 10 7 
21 37 23 15 38 17 16 12 3 32 5 2 30 24 4 36 14 6 40 35 34 33 
21 37 23 15...

result:

ok good!

Test #81:

score: 0
Accepted
time: 58ms
memory: 163600kb

input:

130
5 1 7 5 7 6 4 2 4 2 7 1 5 1 1 7 4 3 3 4 3 5 1 5 5 2 1 6 5 2 7 2 1 2 3 1 1 6 1 5 3 2 1 5 7 6 5 2 5 3 5 4 2 3 1 3 2 4 6 6 1 3 4 7 6 2 7 1 7 7 5 7 2 3 1 2 2 4 4 1 3 4 7 3 7 3 6 1 1 3 3 6 5 7 4 1 4 5 3 3 5 4 4 6 1 3 2 6 4 7 3 4 2 6 1 2 7 7 7 6 5 6 7 5 2 2 2 2 7 2
7
26 43 55 69 82 116 125

output:

7
26 129 123 119 118 117 110 94 85 83 72 70 69 67 64 45 31 16 11 5 3 122 120 114 108 104 92 
69 129 123 119 118 117 110 94 87 85 83 72 70 69 67 65 64 60 59 46 45 38 31 28 16 11 6 5 3 124 122 121 120 114 108 104 101 98 93 92 71 51 49 47 44 40 29 25 24 22 13 4 1 112 109 103 102 97 95 82 79 78 63 58 52...

result:

ok good!

Test #82:

score: 0
Accepted
time: 67ms
memory: 229184kb

input:

130
5 4 7 2 1 6 4 3 4 4 4 3 7 4 5 1 2 1 6 1 7 4 6 4 2 4 2 7 1 3 1 7 1 3 1 2 6 4 7 3 6 5 3 2 6 3 1 7 2 1 1 6 7 6 1 3 4 5 7 1 3 1 5 7 6 3 4 6 1 5 1 5 5 6 3 1 7 6 7 2 5 6 4 7 3 7 4 2 5 2 6 4 1 2 4 1 7 4 4 6 2 5 5 3 4 6 1 2 3 2 2 3 6 1 7 4 1 2 5 4 3 5 5 3 5 2 2 3 5 5
45
1 4 5 6 15 18 20 23 28 31 32 33 3...

output:

7
66 115 97 86 84 79 77 64 59 53 48 39 32 28 21 13 3 113 106 100 91 82 78 74 68 65 54 52 45 41 37 23 19 6 130 129 125 123 122 119 103 102 89 81 73 72 70 63 58 42 15 1 120 116 105 99 98 95 92 87 83 67 57 38 26 24 22 
66 115 97 86 84 79 77 64 59 53 48 39 32 28 21 13 3 113 106 100 91 82 78 74 68 65 54 ...

result:

ok good!

Test #83:

score: 0
Accepted
time: 44ms
memory: 151288kb

input:

130
2 6 1 6 1 4 5 4 3 4 4 7 6 3 6 1 2 7 4 5 1 5 4 2 6 3 6 3 1 1 2 7 2 5 6 1 5 1 6 3 7 4 4 6 6 1 7 1 1 3 2 7 3 6 1 7 2 5 5 1 5 1 1 4 6 2 4 5 1 2 6 2 1 6 4 2 6 4 5 6 5 4 1 5 6 6 1 2 1 6 2 1 6 1 2 6 4 3 1 4 6 3 7 7 7 3 3 5 1 6 2 7 6 6 6 2 4 3 3 7 4 6 3 7 3 2 3 4 1 3
9
2 3 4 6 8 9 10 16 17

output:

30
10 124 120 112 105 104 103 56 52 47 41 
16 32 18 12 124 122 120 115 114 113 112 110 105 104 103 101 96 
16 93 90 86 85 80 77 74 71 65 56 54 52 47 45 44 41 
16 39 35 32 27 25 18 15 13 12 4 2 124 122 120 115 114 
17 113 112 110 108 105 104 103 101 96 93 90 86 85 84 81 80 79 
17 77 74 71 68 65 61 59...

result:

ok good!

Test #84:

score: 0
Accepted
time: 42ms
memory: 114184kb

input:

70
8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 7 7 7 7 7 7 6 6 6 6 6 6 6 6 6 5 5 5 5 5 5 5 5 5 5 5 5
20
1 2 3 4 6 7 8 9 10 13 21 24 30 31 33 40 45 46 54 70

output:

9
45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 49 48 
45 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 
54 2 1 58 57 56 55 54 53 52 51 50 49...

result:

ok good!

Test #85:

score: 0
Accepted
time: 36ms
memory: 144864kb

input:

90
8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 7 7 7 7 6 6 6 6 6 6 6 5 5 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 2 2
20
1 2 3 6 7 8 9 10 13 20 24 30 32 46 53 63 68 69 70 79

output:

8
46 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 37 36 35 34 44 43 42 41 40 39 38 52 51 
46 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 37 36 35 34 50 49 48 47 46 45 44 43 42 
68 33 32 31 30 29 28 27 26 25 24...

result:

ok good!

Test #86:

score: 0
Accepted
time: 44ms
memory: 171524kb

input:

120
8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 7 7 7 7 6 6 6 6 6 6 5 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1
20
1 2 3 4 5 9 10 14 15 19 25 28 30 33 36 77 78 99 108 116

output:

9
25 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 
30 2 1 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 
30 3 2 1 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 
30 10 9 8 7 6 5 4 3 2 1 44 43 42 41 40 39 38 37 3...

result:

ok good!

Test #87:

score: 0
Accepted
time: 88ms
memory: 247932kb

input:

200
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 ...

output:

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

result:

ok good!

Test #88:

score: 0
Accepted
time: 112ms
memory: 304868kb

input:

250
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

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

result:

ok good!

Test #89:

score: 0
Accepted
time: 111ms
memory: 352272kb

input:

300
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

5
12 46 45 44 43 42 41 40 39 38 37 36 35 
61 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 
130 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9...

result:

ok good!

Test #90:

score: 0
Accepted
time: 53ms
memory: 159236kb

input:

100
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 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
49
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 76 77 78 79 80 81 82 83 84 85 ...

output:

18
24 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 
24 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 
24 2 1 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 
24 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 
24 4 3 ...

result:

ok good!

Test #91:

score: 0
Accepted
time: 251ms
memory: 477048kb

input:

446
55 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

55
9 1 446 445 444 443 442 441 440 439 
9 1 438 437 436 435 434 433 432 431 
9 1 430 429 428 427 426 425 424 423 
9 1 422 421 420 419 418 417 416 415 
9 1 414 413 412 411 410 409 408 407 
9 1 406 405 404 403 402 401 400 399 
9 1 398 397 396 395 394 393 392 391 
9 1 390 389 388 387 386 385 384 383 
9...

result:

ok good!

Test #92:

score: 0
Accepted
time: 211ms
memory: 536688kb

input:

470
31 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

31
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
1 1 
470 470 469 468 467 466 465 464 463 462 461 460 459 458 457 456 455 454 453 452 451 450 449 448 447 446 445 444 443 442 441 440 439 438 437 436 435...

result:

ok good!

Test #93:

score: 0
Accepted
time: 16ms
memory: 55756kb

input:

31
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
15
1 2 3 4 5 6 7 24 25 26 27 28 29 30 31

output:

35
6 1 2 3 4 5 6 
6 1 2 3 4 5 7 
6 1 2 3 4 6 5 
6 1 2 3 4 8 7 
7 1 2 3 6 5 4 9 
7 1 2 3 8 7 6 5 
7 1 2 4 3 10 9 8 
7 1 2 7 6 5 4 3 
7 1 2 11 10 9 8 7 
7 1 6 5 4 3 2 12 
7 1 11 10 9 8 7 6 
7 5 4 3 2 1 13 12 
7 11 10 9 8 7 6 5 
7 4 3 2 1 14 13 12 
7 11 10 9 8 7 6 5 
7 4 3 2 1 15 14 13 
7 12 11 10 9 8 ...

result:

ok good!

Test #94:

score: 0
Accepted
time: 40ms
memory: 127444kb

input:

100
1 14 14 8 2 2 5 16 7 1 4 7 7 2 7 2 1 1 4 5 2 14 9 3 7 1 11 4 7 4 2 8 17 1 7 1 7 2 11 3 3 2 1 7 1 9 1 7 3 3 4 2 1 10 1 1 1 3 8 7 1 1 1 2 4 1 3 16 5 9 3 3 1 3 2 3 7 11 1 3 1 11 13 4 1 3 1 17 1 2 1 16 11 4 9 5 6 4 1 2
7
1 2 4 8 16 32 64

output:

18
1 88 
2 33 92 
16 88 68 33 8 92 22 3 2 83 93 82 78 39 27 54 95 
32 88 68 33 8 92 22 3 2 83 93 82 78 39 27 70 54 46 23 95 59 32 4 77 60 48 44 37 35 29 25 15 13 
32 88 68 33 8 92 22 3 2 83 93 82 78 39 27 70 54 46 23 95 59 32 12 9 4 97 77 60 48 44 37 35 29 
32 88 68 33 8 92 22 3 2 83 93 82 78 39 27 ...

result:

ok good!

Test #95:

score: 0
Accepted
time: 130ms
memory: 373500kb

input:

350
3 1 1 2 1 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 2 3 1 1 1 2 2 1 1 1 1 1 1 1 1 1 1 2 1 1 2 2 1 1 2 1 1 1 1 1 1 1 1 1 1 1 2 1 2 2 1 1 1 1 1 1 3 1 1 1 1 2 1 1 1 1 2 2 1 1 1 2 2 1 2 1 1 1 2 2 1 1 5 1 1 2 1 3 1 1 1 1 1 1 2 1 3 1 1 1 2 1 1 1 1 1 1 2 1 1 1 2 1 1 1 1 1 1 1 1 1 1 3 2 1 1 3 1 ...

output:

7
1 308 
2 206 308 
16 247 206 103 344 332 327 308 298 233 322 321 320 305 291 285 280 
32 247 206 103 344 332 327 308 298 276 261 259 254 253 250 233 224 221 147 143 117 108 77 32 1 350 349 347 343 342 335 334 328 
64 247 206 103 344 332 327 325 322 321 320 310 308 305 303 298 296 295 293 291 286 2...

result:

ok good!

Subtask #5:

score: 0
Wrong Answer

Dependency #4:

100%
Accepted

Test #96:

score: 0
Wrong Answer
time: 376ms
memory: 71960kb

input:

27
12 148 141 10 98 1 82 103 145 60 190 102 181 147 152 185 24 134 179 127 141 38 169 93 132 157 49
6
1 5 7 13 17 26

output:

-1

result:

wrong answer you didn't find a solution but jury did

Subtask #6:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%