QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#601400#6339. CookiesDimash63 66ms133064kbC++232.4kb2024-09-29 22:59:322024-09-29 22:59:32

Judging History

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

  • [2024-09-29 22:59:32]
  • 评测
  • 测评结果:63
  • 用时:66ms
  • 内存:133064kb
  • [2024-09-29 22:59:32]
  • 提交

answer

#include <bits/stdc++.h>
    
using namespace std;
    
typedef long long ll;
const int  N = 5e2 + 12, MOD = (int)1e9 + 7;
 
int n, m, b[N], s = 0, val[N], c[N], p[N];
pair<int, int> a[N];
bool dp[N][N][N];
bool check(int j, int k) {
    return (val[k] >= j);
}
void out(int res) {
    vector<int> d;
    int i = m, j = s, k = res;
    while(j) {
        if(dp[i - 1][j][k]) {
            i--;
            continue;
        }
        assert(j - b[i] >= 0);
        j -= b[i];
        k--;
        d.push_back(b[i]);
        if(dp[i - 1][j][k]) {
            i--;
        }
    }
    cout << res << '\n';
    assert((int)d.size() == res);
    for(int i:d) {
        sort(a + 1, a + n + 1);
        reverse(a + 1, a + n + 1);
        cout << i << ' ';
        for(int j = 1; j <= i; j++) {
            a[j].first--;   
            cout << a[j].second << ' ';
        }
        cout << '\n';
    }
}
void test() {
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> a[i].first, c[i] = a[i].first;
        s += c[i];
        a[i].second = i;
    }
    sort(a + 1, a + n + 1);
    sort(c + 1, c + n + 1);
    for(int i = 1; i <= n; i++) {
        p[i] = p[i - 1] + c[i];
    }
    int it = n;
    for(int i = s; i >= 1; i--) {
        while(it >= 1 && c[it] >= i) {
            it--;
        }
        val[i] = p[it] + (n - it) * 1ll * i;
    }
    cin >> m;
    for(int i = 1; i <= m; i++) {
        cin >> b[i];
    }
    reverse(b + 1, b + m + 1);
    for(int i = 0; i <= m; ++i) {
        dp[i][0][0] = 1;
    }
    for(int i = 1; i <= m; i++) {
        for(int j = 1; j <= s; j++) {
            for(int k = 1; k <= s; k++) {
                dp[i][j][k] = dp[i - 1][j][k];
                // if(i == 1 && j == 2 && k == 2) {
                //     cout << check(j, k);
                // }
                if(j - b[i] >= 0 && (dp[i - 1][j - b[i]][k - 1] || dp[i][j - b[i]][k - 1]) && check(j, k)) {
                    // cout << i << ' ' << j << ' ' << k << '\n';
                    dp[i][j][k] = 1;
                }
            }
        }
    }
    for(int i = 1; i <= s; i++) {
        if(dp[m][s][i]) {
            out(i);
            return;
        }
    }
    cout << -1 << '\n';
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); 
    
    int t = 1; 
    // cin >> t;
    
    while(t--) 
        test();
    return 0;
}

详细

Subtask #1:

score: 6
Accepted

Test #1:

score: 6
Accepted
time: 0ms
memory: 3604kb

input:

1
1
1
1

output:

1
1 1 

result:

ok good!

Test #2:

score: 6
Accepted
time: 0ms
memory: 3536kb

input:

2
1 1
1
1

output:

2
1 2 
1 1 

result:

ok good!

Test #3:

score: 6
Accepted
time: 0ms
memory: 3536kb

input:

2
1 1
1
2

output:

1
2 2 1 

result:

ok good!

Test #4:

score: 6
Accepted
time: 0ms
memory: 3604kb

input:

2
1 1
2
1 2

output:

1
2 2 1 

result:

ok good!

Test #5:

score: 6
Accepted
time: 0ms
memory: 3616kb

input:

4
1 1 1 1
2
2 3

output:

2
2 4 3 
2 2 1 

result:

ok good!

Test #6:

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

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: 6
Accepted
time: 3ms
memory: 4080kb

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

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: 6
Accepted
time: 66ms
memory: 133064kb

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: 6
Accepted
time: 26ms
memory: 69188kb

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: 6
Accepted
time: 7ms
memory: 15552kb

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
45 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 
45 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: 6
Accepted
time: 15ms
memory: 37728kb

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: 6
Accepted
time: 25ms
memory: 64724kb

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: 6
Accepted
time: 28ms
memory: 62068kb

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: 6
Accepted
time: 27ms
memory: 67704kb

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

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

result:

ok good!

Test #17:

score: 6
Accepted
time: 3ms
memory: 6440kb

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: 6
Accepted
time: 2ms
memory: 6140kb

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
64 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 
64 435 434 433 432 431 430 429 428 427...

result:

ok good!

Test #19:

score: 6
Accepted
time: 3ms
memory: 7876kb

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: 6
Accepted
time: 15ms
memory: 30872kb

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: 6
Accepted
time: 33ms
memory: 68868kb

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: 6
Accepted
time: 36ms
memory: 67452kb

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: 6
Accepted
time: 6ms
memory: 13132kb

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

result:

ok good!

Test #24:

score: 6
Accepted
time: 3ms
memory: 12220kb

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

result:

ok good!

Test #25:

score: 6
Accepted
time: 6ms
memory: 11368kb

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 
33 429 428 427 426 425 42...

result:

ok good!

Test #26:

score: 6
Accepted
time: 3ms
memory: 11456kb

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: 6
Accepted
time: 18ms
memory: 42624kb

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 
33 429 428 427 426 425 42...

result:

ok good!

Subtask #2:

score: 0
Runtime Error

Test #28:

score: 7
Accepted
time: 1ms
memory: 5576kb

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

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: 0
Runtime Error

input:

1
3000
1
1

output:


result:


Subtask #3:

score: 12
Accepted

Test #45:

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

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

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

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

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

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: 12
Accepted
time: 1ms
memory: 5584kb

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

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

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

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: 12
Accepted
time: 1ms
memory: 5636kb

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

input:

6
3 3 3 2 2 2
3
2 4 6

output:

-1

result:

ok no solution

Test #56:

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

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

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

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

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: 12
Accepted
time: 1ms
memory: 5608kb

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

input:

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

output:

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

result:

ok good!

Test #62:

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

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

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

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: 12
Accepted
time: 1ms
memory: 5660kb

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

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

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: 5ms
memory: 9264kb

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: 45
Accepted
time: 4ms
memory: 8340kb

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: 45
Accepted
time: 4ms
memory: 9936kb

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: 45
Accepted
time: 3ms
memory: 6964kb

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

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: 45
Accepted
time: 4ms
memory: 9052kb

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: 45
Accepted
time: 4ms
memory: 7976kb

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: 45
Accepted
time: 3ms
memory: 7696kb

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: 45
Accepted
time: 3ms
memory: 7276kb

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

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: 45
Accepted
time: 2ms
memory: 6720kb

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: 45
Accepted
time: 2ms
memory: 5680kb

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
13 20 1 40 3 35 28 12 7 2 21 16 32 27 
13 20 1 40 3 35 28 12 7 2 21 16 8 32 
13 20 1 40 3 35 28 12 7 2 27 25 21 18 
13 20 1 40 3 35 28 12 7 2 16 8 32 27 
13 20 1 40 3 35 28 12 7 2 25 21 18 16 
13 20 1 40 3 35 28 12 7 2 8 32 27 25 
13 20 1 40 3 35 28 12 7 2 23 21 18 16 
13 20 1 40 3 35 28 12 14 8 ...

result:

ok good!

Test #80:

score: 45
Accepted
time: 4ms
memory: 7340kb

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
14 37 23 15 38 17 16 12 3 32 5 2 4 36 30 
21 37 23 15 38 17 16 12 3 32 5 2 24 4 36 30 14 6 33 35 34 11 
21 37 23 15 38 17 16 12 3 32 5 2 24 4 36 30 14 6 33 35 34 27 
21 37 23 15 38 17 16 12 3 32 5 2 24 4 36 30 14 6 33 11 10 7 
21 37 23 15 38 17 16 12 3 32 5 2 24 4 36 30 14 6 40 35 34 33 
21 37 23...

result:

ok good!

Test #81:

score: 45
Accepted
time: 2ms
memory: 6268kb

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
55 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 87 65 60 59 46 38 28 6 124 121 101 98 93 71 51 49 47 44 40 29 25 24 22 13 4 1 112 109 103 
55 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 87 65 60 59 46 38 28 6 124 ...

result:

ok good!

Test #82:

score: 45
Accepted
time: 6ms
memory: 16880kb

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: 45
Accepted
time: 3ms
memory: 7236kb

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

result:

ok good!

Test #84:

score: 45
Accepted
time: 5ms
memory: 10228kb

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: 45
Accepted
time: 5ms
memory: 9684kb

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
53 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 50 49 48 47 46 45 66 
63 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 65 64 63 62 61 60 ...

result:

ok good!

Test #86:

score: 45
Accepted
time: 5ms
memory: 9908kb

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
36 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 31 30 29 28 37 36 35 34 33 
36 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 32 31 30 29 28 44 43 42 41 
36 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 40 39 38 37 36 35...

result:

ok good!

Test #87:

score: 45
Accepted
time: 5ms
memory: 10392kb

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: 45
Accepted
time: 5ms
memory: 10172kb

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: 45
Accepted
time: 5ms
memory: 10144kb

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
33 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 
37 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 
45 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 ...

result:

ok good!

Test #90:

score: 45
Accepted
time: 5ms
memory: 16860kb

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: 45
Accepted
time: 62ms
memory: 116924kb

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: 45
Accepted
time: 32ms
memory: 64100kb

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: 45
Accepted
time: 4ms
memory: 9540kb

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: 45
Accepted
time: 3ms
memory: 6696kb

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: 45
Accepted
time: 3ms
memory: 6392kb

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
Runtime Error

Dependency #4:

100%
Accepted

Test #96:

score: 0
Runtime Error

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:


result:


Subtask #6:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%