QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#401383 | #2555. Two Bullets | nguyentunglam | WA | 4ms | 10068kb | C++17 | 4.7kb | 2024-04-28 16:37:06 | 2024-04-28 16:37:07 |
Judging History
answer
#include<bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define endl "\n"
using namespace std;
const int N = 1e5 + 10, K = 200;
int a[N], deg[N], rev_idx[N], cost[N];
int n;
int st[N / K], ed[N / K];
vector<int> rrh[N / K];
struct IT {
int lazy[K * 4];
pair<int, int> T[K * 4];
void build(int s, int l, int r) {
if (l == r) {
T[s] = make_pair(0, l);
return;
}
int mid = l + r >> 1;
build(s << 1, l, mid);
build(s << 1 | 1, mid + 1, r);
T[s] = min(T[s << 1], T[s << 1 | 1]);
}
void push(int s, int l, int r) {
if (!lazy[s]) return;
T[s].first += lazy[s];
if (l != r) {
lazy[s << 1] += lazy[s];
lazy[s << 1 | 1] += lazy[s];
}
lazy[s] = 0;
}
void up(int s, int l, int r, int from, int to, int val) {
push(s, l, r);
if (l > to || r < from) return;
if (from <= l && r <= to) {
lazy[s] = val;
push(s, l, r);
return;
}
int mid = l + r >> 1;
up(s << 1, l, mid, from, to, val);
up(s << 1 | 1, mid + 1, r, from, to, val);
T[s] = min(T[s << 1], T[s << 1 | 1]);
}
} it[N / K];
int bit[N];
void add (int pos, int val) {
while (pos) {
bit[pos] += val;
pos -= pos & -pos;
}
}
int get(int pos) {
int ret = 0;
while (pos <= n) {
ret += bit[pos];
pos += pos & -pos;
}
return ret;
}
vector<int> q[2];
int32_t main() {
#define task ""
cin.tie(0) -> sync_with_stdio(0);
if (fopen("task.inp", "r")) {
freopen("task.inp", "r", stdin);
freopen("task.out", "w", stdout);
}
if (fopen(task".inp", "r")) {
freopen (task".inp", "r", stdin);
freopen (task".out", "w", stdout);
}
cin >> n;
for(int i = 1; i <= n; i++) cin >> a[i];
for(int i = 1; i <= n; i++) rev_idx[a[i]] = i;
for(int i = 1; i <= n; i++) {
cost[i] = get(a[i]);
add(a[i], 1);
}
for(int i = n, mn = 1e9; i >= 1; i--) {
deg[i] = a[i] > mn;
mn = min(mn, a[i]);
}
auto idx = [&] (int block, int val) {
return upper_bound(all(rrh[block]), val) - rrh[block].begin();
};
auto handle = [&] (int block) {
// if (block == 2) cout << it[block].T[1].first << endl;
while (it[block].T[1].first == 0) {
int x = it[block].T[1].second;
it[block].up(1, 1, ed[block] - st[block] + 1, x, x, 1e9);
int y = rev_idx[rrh[block][x - 1]];
// if (y == 4) cout << x << " " << block << endl;
q[deg[y]].push_back(y);
}
};
for(int block = 0; block <= n / K; block++) {
st[block] = max(1, block * K);
ed[block] = min(n, block * K + K - 1);
for(int i = st[block]; i <= ed[block]; i++) rrh[block].push_back(a[i]);
sort(all(rrh[block]));
rrh[block].resize(unique(all(rrh[block])) - rrh[block].begin());
// cout << ed[block] - st[block] + 1 << endl;
it[block].build(1, 1, ed[block] - st[block] + 1);
for(int i = st[block]; i <= ed[block]; i++) {
int pos = idx(block, a[i]);
// cout << i << " " << block << " " << pos << " " << cost[i] << endl;
it[block].up(1, 1, ed[block] - st[block] + 1, pos, pos, cost[i]);
}
// if (block == 2) {
// cout << it[block].T[1].first << " " << it[block].T[1].second << endl;
// }
handle(block);
}
// exit(0);
auto del = [&] (int i) {
int group = i / K;
for(int j = i + 1; j <= ed[group]; j++) if (a[i] > a[j]) {
int pos = idx(group, a[j]);
it[group].up(1, 1, ed[group] - st[group] + 1, pos, pos, -1);
}
// exit(0);
handle(group);
for(int block = group + 1; block <= n / K; block++) {
int pos = idx(block, a[i]);
if (!pos) continue;
it[block].up(1, 1, ed[block] - st[block] + 1, 1, pos, -1);
handle(block);
}
};
vector<pair<int, int> > ans;
// del(1);
// cout << q[0].size() << endl;
// for(int &j : q[0]) cout << j << " "; cout << endl;
// exit(0);
while (1) {
if (q[1].size() >= 2) {
int x = q[1].back(); q[1].pop_back();
int y = q[1].back(); q[1].pop_back();
ans.emplace_back(a[x], a[y]);
del(x);
del(y);
}
else if (q[1].size() == 1) {
int x = q[1].back(); q[1].pop_back();
if (q[0].empty()) ans.emplace_back(a[x], a[x]);
else {
int y = q[0].back(); q[0].pop_back();
ans.emplace_back(a[x], a[y]);
}
del(x);
}
else {
if (q[0].empty()) break;
int x = q[0].back(); q[0].pop_back();
if (q[0].empty()) {
ans.emplace_back(a[x], a[x]);
break;
}
int y = q[0].back(); q[0].pop_back();
ans.emplace_back(a[x], a[y]);
}
}
cout << ans.size() << endl;
for(auto &[x, y] : ans) cout << x << " " << y << endl;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 10068kb
input:
8 4 3 8 2 1 7 6 5
output:
4 8 4 3 7 6 2 1 5
result:
ok da
Test #2:
score: 0
Accepted
time: 1ms
memory: 9952kb
input:
8 5 6 7 1 2 8 3 4
output:
4 8 7 6 5 4 3 2 1
result:
ok da
Test #3:
score: 0
Accepted
time: 1ms
memory: 9956kb
input:
4 1 2 4 3
output:
2 4 2 3 1
result:
ok da
Test #4:
score: 0
Accepted
time: 0ms
memory: 8964kb
input:
2 1 2
output:
1 2 1
result:
ok da
Test #5:
score: 0
Accepted
time: 1ms
memory: 8344kb
input:
2 2 1
output:
2 2 2 1 1
result:
ok da
Test #6:
score: 0
Accepted
time: 1ms
memory: 8576kb
input:
3 1 2 3
output:
2 3 2 1 1
result:
ok da
Test #7:
score: 0
Accepted
time: 1ms
memory: 8272kb
input:
3 1 3 2
output:
2 3 1 2 2
result:
ok da
Test #8:
score: 0
Accepted
time: 1ms
memory: 8340kb
input:
3 2 1 3
output:
2 2 3 1 1
result:
ok da
Test #9:
score: 0
Accepted
time: 1ms
memory: 8708kb
input:
3 2 3 1
output:
2 3 2 1 1
result:
ok da
Test #10:
score: 0
Accepted
time: 1ms
memory: 8496kb
input:
3 3 1 2
output:
2 3 3 2 1
result:
ok da
Test #11:
score: 0
Accepted
time: 0ms
memory: 9796kb
input:
3 3 2 1
output:
3 3 3 2 2 1 1
result:
ok da
Test #12:
score: 0
Accepted
time: 0ms
memory: 8280kb
input:
4 1 2 3 4
output:
2 4 3 2 1
result:
ok da
Test #13:
score: 0
Accepted
time: 0ms
memory: 9164kb
input:
4 1 2 4 3
output:
2 4 2 3 1
result:
ok da
Test #14:
score: 0
Accepted
time: 1ms
memory: 8572kb
input:
4 1 3 2 4
output:
2 3 4 2 1
result:
ok da
Test #15:
score: 0
Accepted
time: 1ms
memory: 8528kb
input:
4 1 3 4 2
output:
2 4 3 2 1
result:
ok da
Test #16:
score: 0
Accepted
time: 1ms
memory: 8476kb
input:
4 1 4 2 3
output:
2 4 1 3 2
result:
ok da
Test #17:
score: 0
Accepted
time: 0ms
memory: 9000kb
input:
4 1 4 3 2
output:
3 4 1 3 3 2 2
result:
ok da
Test #18:
score: 0
Accepted
time: 1ms
memory: 9184kb
input:
4 2 1 3 4
output:
2 2 4 1 3
result:
ok da
Test #19:
score: 0
Accepted
time: 1ms
memory: 9120kb
input:
4 2 1 4 3
output:
2 4 2 1 3
result:
ok da
Test #20:
score: 0
Accepted
time: 1ms
memory: 9108kb
input:
4 2 3 1 4
output:
2 3 2 1 4
result:
ok da
Test #21:
score: 0
Accepted
time: 1ms
memory: 9076kb
input:
4 2 3 4 1
output:
3 4 3 2 2 1 1
result:
ok da
Test #22:
score: 0
Accepted
time: 1ms
memory: 8300kb
input:
4 2 4 1 3
output:
2 4 2 1 3
result:
ok da
Test #23:
score: 0
Accepted
time: 0ms
memory: 9328kb
input:
4 2 4 3 1
output:
3 4 2 3 3 1 1
result:
ok da
Test #24:
score: 0
Accepted
time: 1ms
memory: 8708kb
input:
4 3 1 2 4
output:
2 3 4 2 1
result:
ok da
Test #25:
score: 0
Accepted
time: 1ms
memory: 8844kb
input:
4 3 1 4 2
output:
2 4 3 2 1
result:
ok da
Test #26:
score: 0
Accepted
time: 0ms
memory: 8576kb
input:
4 3 2 1 4
output:
3 3 4 2 2 1 1
result:
ok da
Test #27:
score: 0
Accepted
time: 1ms
memory: 9648kb
input:
4 3 2 4 1
output:
3 4 3 2 2 1 1
result:
ok da
Test #28:
score: 0
Accepted
time: 2ms
memory: 9080kb
input:
4 3 4 1 2
output:
2 4 3 2 1
result:
ok da
Test #29:
score: 0
Accepted
time: 1ms
memory: 9300kb
input:
4 3 4 2 1
output:
3 4 3 2 2 1 1
result:
ok da
Test #30:
score: 0
Accepted
time: 1ms
memory: 9776kb
input:
4 4 1 2 3
output:
3 4 4 3 2 1 1
result:
ok da
Test #31:
score: 0
Accepted
time: 0ms
memory: 8280kb
input:
4 4 1 3 2
output:
3 4 4 3 1 2 2
result:
ok da
Test #32:
score: 0
Accepted
time: 1ms
memory: 9776kb
input:
4 4 2 1 3
output:
3 4 4 2 3 1 1
result:
ok da
Test #33:
score: 0
Accepted
time: 1ms
memory: 10008kb
input:
4 4 2 3 1
output:
3 4 4 3 2 1 1
result:
ok da
Test #34:
score: 0
Accepted
time: 1ms
memory: 8840kb
input:
4 4 3 1 2
output:
3 4 4 3 3 2 1
result:
ok da
Test #35:
score: 0
Accepted
time: 1ms
memory: 9056kb
input:
4 4 3 2 1
output:
4 4 4 3 3 2 2 1 1
result:
ok da
Test #36:
score: 0
Accepted
time: 1ms
memory: 9100kb
input:
16 13 7 10 1 9 15 4 11 12 2 8 16 3 5 14 6
output:
8 16 15 14 13 12 11 10 7 9 1 8 4 3 2 6 5
result:
ok da
Test #37:
score: 0
Accepted
time: 1ms
memory: 9768kb
input:
16 12 16 11 15 10 9 8 4 14 13 7 2 6 5 3 1
output:
10 16 12 11 15 14 10 9 13 8 8 7 4 2 6 5 5 3 3 1 1
result:
ok da
Test #38:
score: 0
Accepted
time: 1ms
memory: 8968kb
input:
16 2 4 5 1 9 10 3 6 14 7 8 11 12 16 13 15
output:
8 16 14 10 9 5 4 2 3 1 8 7 6 13 12 11 15
result:
ok da
Test #39:
score: 0
Accepted
time: 0ms
memory: 9412kb
input:
16 13 7 10 1 9 15 4 11 12 2 8 16 3 5 14 6
output:
8 16 15 14 13 12 11 10 7 9 1 8 4 3 2 6 5
result:
ok da
Test #40:
score: 0
Accepted
time: 0ms
memory: 9896kb
input:
16 16 13 10 7 6 15 14 12 5 11 4 9 3 8 1 2
output:
9 16 16 15 13 10 14 12 7 6 11 9 5 4 8 3 3 2 1
result:
ok da
Test #41:
score: 0
Accepted
time: 0ms
memory: 8672kb
input:
16 2 3 1 8 12 4 5 6 7 14 15 9 10 16 11 13
output:
8 16 15 14 12 8 3 2 7 1 6 5 4 11 10 9 13
result:
ok da
Test #42:
score: 0
Accepted
time: 0ms
memory: 8880kb
input:
16 13 7 10 1 9 15 4 11 12 2 8 16 3 5 14 6
output:
8 16 15 14 13 12 11 10 7 9 1 8 4 3 2 6 5
result:
ok da
Test #43:
score: 0
Accepted
time: 1ms
memory: 8356kb
input:
16 16 13 10 15 8 14 12 7 4 11 9 6 1 5 3 2
output:
10 16 16 15 13 10 14 12 8 7 11 9 4 6 6 5 1 3 3 2 2
result:
ok da
Test #44:
score: 0
Accepted
time: 0ms
memory: 9780kb
input:
16 3 5 1 6 8 9 2 11 12 4 7 14 15 10 16 13
output:
8 16 15 14 12 11 9 8 6 5 3 2 1 4 7 10 13
result:
ok da
Test #45:
score: 0
Accepted
time: 0ms
memory: 8628kb
input:
16 13 7 10 1 9 15 4 11 12 2 8 16 3 5 14 6
output:
8 16 15 14 13 12 11 10 7 9 1 8 4 3 2 6 5
result:
ok da
Test #46:
score: 0
Accepted
time: 0ms
memory: 9784kb
input:
16 14 13 12 11 16 15 8 10 6 9 4 7 3 1 5 2
output:
9 16 14 13 15 12 12 11 11 10 8 6 9 7 4 3 5 2 1
result:
ok da
Test #47:
score: 0
Accepted
time: 1ms
memory: 9268kb
input:
16 1 7 2 3 9 11 4 5 6 12 15 8 10 16 13 14
output:
8 16 15 12 11 9 7 6 5 4 3 2 8 10 14 13 1
result:
ok da
Test #48:
score: 0
Accepted
time: 1ms
memory: 8944kb
input:
16 13 7 10 1 9 15 4 11 12 2 8 16 3 5 14 6
output:
8 16 15 14 13 12 11 10 7 9 1 8 4 3 2 6 5
result:
ok da
Test #49:
score: 0
Accepted
time: 1ms
memory: 8576kb
input:
16 14 13 16 11 9 15 12 6 5 10 8 7 2 1 4 3
output:
8 16 14 13 15 12 11 10 9 8 6 5 7 4 2 1 3
result:
ok da
Test #50:
score: 0
Accepted
time: 1ms
memory: 8624kb
input:
16 6 7 8 1 9 2 3 4 11 12 5 10 13 14 15 16
output:
8 12 11 9 8 7 6 5 4 3 2 1 10 16 15 14 13
result:
ok da
Test #51:
score: 0
Accepted
time: 1ms
memory: 9780kb
input:
16 13 7 10 1 9 15 4 11 12 2 8 16 3 5 14 6
output:
8 16 15 14 13 12 11 10 7 9 1 8 4 3 2 6 5
result:
ok da
Test #52:
score: 0
Accepted
time: 1ms
memory: 8492kb
input:
16 15 16 14 12 11 9 7 5 4 13 2 10 1 8 6 3
output:
10 16 15 14 14 13 12 11 11 10 9 8 7 6 5 4 4 2 3 1 1
result:
ok da
Test #53:
score: 0
Accepted
time: 1ms
memory: 8576kb
input:
16 1 6 2 7 8 9 10 13 3 4 5 11 14 12 16 15
output:
8 16 14 13 10 9 8 7 6 5 4 3 2 12 11 15 1
result:
ok da
Test #54:
score: 0
Accepted
time: 3ms
memory: 8588kb
input:
495 237 201 155 129 345 454 113 11 492 357 300 295 198 442 14 79 288 431 343 64 285 101 316 15 34 293 3 393 384 47 296 402 488 328 128 409 110 72 249 115 386 450 167 214 489 227 172 220 336 59 206 315 278 63 395 478 490 165 164 303 449 145 31 418 119 179 373 320 93 255 183 38 58 491 375 416 430 326 ...
output:
248 495 494 493 492 491 490 489 488 487 486 485 478 477 476 475 484 473 465 471 468 457 470 462 456 455 483 482 480 474 472 469 481 479 467 466 463 464 461 460 459 458 454 453 452 451 450 449 442 431 448 447 446 445 441 439 436 434 444 443 430 429 427 425 423 421 428 426 424 422 440 438 437 435 418 ...
result:
ok da
Test #55:
score: 0
Accepted
time: 4ms
memory: 8916kb
input:
495 492 491 487 481 495 494 493 480 490 478 489 488 477 486 485 475 472 484 483 471 468 482 479 466 465 463 476 461 460 459 474 457 473 455 454 470 469 453 452 467 450 449 464 462 448 447 458 456 443 451 446 442 445 437 436 435 434 433 429 444 427 426 441 440 439 424 423 438 421 419 416 432 413 431 ...
output:
250 495 492 491 494 493 487 481 490 489 480 478 488 486 477 485 485 484 475 472 483 482 471 468 479 476 466 465 474 473 463 461 470 469 460 459 467 464 457 455 462 458 454 453 456 452 452 451 450 449 449 448 448 447 447 446 443 442 445 444 437 436 441 440 435 434 439 438 433 432 429 427 431 430 426 ...
result:
ok da
Test #56:
score: 0
Accepted
time: 2ms
memory: 9536kb
input:
495 5 6 7 9 10 1 2 12 3 13 15 17 18 19 20 24 4 8 11 26 27 29 30 31 33 14 16 21 34 35 39 22 40 43 23 44 25 28 32 47 36 37 48 38 53 56 41 57 42 45 46 49 50 60 62 63 65 51 52 54 55 58 59 69 71 61 72 64 66 74 77 67 68 80 70 81 84 87 88 89 90 92 73 96 75 97 98 76 99 102 78 79 82 83 105 106 85 86 91 110 9...
output:
248 494 493 492 490 489 487 486 485 482 481 479 477 476 474 473 472 470 468 460 459 458 457 456 455 454 452 447 446 445 444 443 442 440 436 435 434 433 432 430 429 426 424 423 422 421 420 419 418 411 409 408 407 405 399 398 397 396 392 391 390 389 383 381 380 379 378 376 374 373 372 370 368 367 365 ...
result:
ok da
Test #57:
score: 0
Accepted
time: 4ms
memory: 9732kb
input:
496 237 201 155 129 345 454 113 11 492 357 300 295 198 442 14 79 288 431 343 64 285 101 316 15 34 293 3 393 384 47 296 402 488 328 128 409 110 72 249 115 386 450 167 214 489 227 172 220 336 59 206 315 278 63 395 478 490 165 164 303 449 145 31 418 119 179 373 320 93 255 183 38 58 491 375 416 496 326 ...
output:
248 496 492 491 490 489 488 478 495 475 494 493 487 486 485 484 483 482 480 481 477 479 476 474 473 472 471 470 468 469 465 463 462 461 458 457 467 466 456 455 464 460 459 454 345 453 452 451 450 449 442 431 448 447 446 445 441 439 436 434 429 428 444 443 427 426 425 424 423 422 421 440 435 433 438 ...
result:
ok da
Test #58:
score: 0
Accepted
time: 4ms
memory: 8576kb
input:
496 493 491 486 496 481 495 494 492 490 489 473 488 487 472 469 468 485 484 483 464 482 480 463 479 478 477 460 458 476 475 457 456 474 471 455 454 470 453 452 467 449 448 447 446 466 437 465 436 433 432 430 428 462 426 461 425 424 421 420 419 459 417 416 451 410 450 409 408 407 445 405 444 443 442 ...
output:
262 496 493 491 495 494 486 481 492 490 490 489 489 488 473 487 487 485 472 469 484 483 468 464 482 480 480 479 463 478 478 477 477 476 460 458 475 474 457 456 471 470 455 454 467 466 453 452 465 462 449 448 461 459 447 446 451 450 437 436 445 444 433 432 443 442 430 428 441 440 426 425 439 438 424 ...
result:
ok da
Test #59:
score: 0
Accepted
time: 0ms
memory: 9012kb
input:
496 1 5 6 8 9 11 13 2 3 14 4 7 16 10 12 15 19 21 24 26 29 31 17 32 18 33 20 35 39 22 41 44 23 47 25 48 27 28 30 51 34 54 36 37 38 40 42 55 43 45 56 58 46 49 50 52 59 60 53 67 57 68 61 62 63 64 70 74 65 66 75 76 77 69 81 83 71 72 85 73 86 88 89 90 92 94 96 78 100 101 104 107 110 79 111 80 82 112 113 ...
output:
248 496 494 493 492 489 488 487 486 485 484 482 480 478 477 476 475 472 471 469 467 465 464 463 462 461 459 457 456 455 453 452 450 449 448 445 442 438 436 435 434 433 429 427 424 421 417 416 415 414 413 410 408 406 404 403 399 396 394 393 392 391 390 389 386 385 379 378 375 373 372 371 370 369 366 ...
result:
ok da
Test #60:
score: 0
Accepted
time: 3ms
memory: 9792kb
input:
497 237 201 155 129 345 454 113 11 492 357 300 295 198 442 14 79 288 431 343 64 285 101 316 15 34 293 3 393 384 47 296 402 488 328 128 409 110 72 249 115 386 450 167 214 489 227 172 220 336 59 206 315 278 63 395 478 490 165 164 303 449 145 31 418 119 179 373 320 93 255 183 38 58 491 375 416 496 326 ...
output:
249 497 496 495 494 493 492 491 490 489 488 487 486 485 478 477 476 475 484 473 465 471 468 457 470 462 456 455 483 482 480 474 472 469 481 479 467 466 463 464 461 460 459 458 454 453 452 451 450 449 442 431 448 447 446 445 441 439 436 434 429 428 444 443 427 426 425 424 423 422 421 440 435 433 438 ...
result:
ok da
Test #61:
score: 0
Accepted
time: 4ms
memory: 8588kb
input:
497 496 492 490 489 497 495 494 493 488 486 485 484 480 478 491 487 475 483 474 482 471 468 465 464 460 459 481 458 457 456 479 477 455 453 476 473 450 444 443 440 472 439 470 469 435 433 467 432 430 466 429 463 462 428 461 425 420 419 454 418 452 451 416 449 415 413 412 448 409 402 401 400 447 399 ...
output:
259 497 496 495 492 490 494 493 489 488 491 487 486 485 485 484 484 483 480 478 482 481 475 474 479 477 471 468 476 473 465 464 472 470 460 459 469 467 458 457 466 463 456 455 462 461 453 450 454 452 444 443 451 449 440 439 448 447 435 433 446 445 432 430 442 441 429 428 438 437 425 420 436 434 419 ...
result:
ok da
Test #62:
score: 0
Accepted
time: 2ms
memory: 9832kb
input:
497 6 1 2 10 11 3 12 4 15 5 7 8 16 17 18 19 21 25 26 30 31 9 32 13 14 20 33 35 37 40 41 43 22 45 23 46 24 27 49 50 28 52 53 29 54 58 59 34 36 38 39 42 44 47 61 48 51 63 55 67 68 69 56 57 72 60 62 77 78 79 80 64 65 82 85 87 88 66 89 91 98 102 70 104 71 111 112 113 117 118 120 73 125 129 130 74 75 131...
output:
249 497 496 495 494 492 490 489 488 486 485 483 482 481 479 478 475 473 472 469 465 464 463 458 457 456 453 452 451 449 447 445 443 440 439 437 434 433 432 431 430 429 427 424 420 416 414 413 412 411 410 405 401 400 397 394 392 391 389 387 386 385 384 383 376 375 373 372 371 370 368 367 366 364 363 ...
result:
ok da
Test #63:
score: -100
Wrong Answer
time: 3ms
memory: 8592kb
input:
498 237 201 155 129 345 454 113 11 492 357 300 295 198 442 14 79 288 431 343 64 285 101 316 15 34 293 3 393 384 47 296 402 488 328 128 409 110 72 249 115 386 450 167 214 489 227 172 220 336 59 206 315 278 63 395 478 490 165 164 303 449 145 31 418 119 179 373 320 93 255 183 38 58 491 375 416 496 326 ...
output:
250 498 496 494 497 495 492 491 490 489 488 487 486 485 478 477 476 475 484 473 465 471 468 457 470 462 456 455 483 482 480 474 472 469 458 467 463 466 461 459 493 481 454 453 452 451 450 449 442 431 448 447 446 445 441 439 436 434 429 428 444 443 427 426 425 424 423 422 421 440 435 433 438 437 418 ...
result:
wrong answer jury have better solution