QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#401283#2555. Two BulletsnguyentunglamTL 113ms137744kbC++171.8kb2024-04-28 13:04:092024-04-28 13:04:09

Judging History

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

  • [2024-04-28 13:04:09]
  • 评测
  • 测评结果:TL
  • 用时:113ms
  • 内存:137744kb
  • [2024-04-28 13:04:09]
  • 提交

answer

#include<bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define endl "\n"
using namespace std;

const int N = 1e5 + 10;

int a[N], deg[N];

int n;

vector<int> adj[N];

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++) for(int j = i + 1; j <= n; j++) if (a[i] > a[j]) {
    deg[j]++;
    adj[i].push_back(j);
  }

  queue<int> q, free;
  for(int i = 1; i <= n; i++) if (deg[i] == 0) {
    if (adj[i].empty()) free.push(i);
    else q.push(i);
  }

  auto del = [&] (int u) {
    for(int &v : adj[u]) {
      deg[v]--;
      if (deg[v] == 0) {
        if (adj[v].empty()) free.push(v);
        else q.push(v);
      }
    }
  };

  vector<pair<int, int> > ans;

  while (1) {
    if (q.size() >= 2) {
      int x = q.front(); q.pop();
      int y = q.front(); q.pop();
      ans.emplace_back(a[x], a[y]);
      del(x);
      del(y);
    }
    else if (q.size() == 1) {
      int x = q.front(); q.pop();
      if (free.empty()) ans.emplace_back(a[x], a[x]);
      else {
        int y = free.front(); free.pop();
        ans.emplace_back(a[x], a[y]);
      }
      del(x);
    }
    else {
      if (free.empty()) break;
      int x = free.front(); free.pop();
      if (free.empty()) {
        ans.emplace_back(a[x], a[x]);
        break;
      }
      int y = free.front(); free.pop();
      ans.emplace_back(a[x], a[y]);
    }
  }

  cout << ans.size() << endl;

  for(auto &[x, y] : ans) cout << x << " " << y << endl;
}




詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 6316kb

input:

8
4 3 8 2 1 7 6 5

output:

4
4 8
3 7
2 6
1 5

result:

ok da

Test #2:

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

input:

8
5 6 7 1 2 8 3 4

output:

4
5 6
7 8
1 2
3 4

result:

ok da

Test #3:

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

input:

4
1 2 4 3

output:

2
4 1
2 3

result:

ok da

Test #4:

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

input:

2
1 2

output:

1
1 2

result:

ok da

Test #5:

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

input:

2
2 1

output:

2
2 2
1 1

result:

ok da

Test #6:

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

input:

3
1 2 3

output:

2
1 2
3 3

result:

ok da

Test #7:

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

input:

3
1 3 2

output:

2
3 1
2 2

result:

ok da

Test #8:

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

input:

3
2 1 3

output:

2
2 3
1 1

result:

ok da

Test #9:

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

input:

3
2 3 1

output:

2
2 3
1 1

result:

ok da

Test #10:

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

input:

3
3 1 2

output:

2
3 3
1 2

result:

ok da

Test #11:

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

input:

3
3 2 1

output:

3
3 3
2 2
1 1

result:

ok da

Test #12:

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

input:

4
1 2 3 4

output:

2
1 2
3 4

result:

ok da

Test #13:

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

input:

4
1 2 4 3

output:

2
4 1
2 3

result:

ok da

Test #14:

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

input:

4
1 3 2 4

output:

2
3 1
4 2

result:

ok da

Test #15:

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

input:

4
1 3 4 2

output:

2
3 4
1 2

result:

ok da

Test #16:

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

input:

4
1 4 2 3

output:

2
4 1
2 3

result:

ok da

Test #17:

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

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: 6160kb

input:

4
2 1 3 4

output:

2
2 3
4 1

result:

ok da

Test #19:

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

input:

4
2 1 4 3

output:

2
2 4
1 3

result:

ok da

Test #20:

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

input:

4
2 3 1 4

output:

2
2 3
4 1

result:

ok da

Test #21:

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

input:

4
2 3 4 1

output:

3
2 3
4 4
1 1

result:

ok da

Test #22:

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

input:

4
2 4 1 3

output:

2
2 4
1 3

result:

ok da

Test #23:

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

input:

4
2 4 3 1

output:

3
2 4
3 3
1 1

result:

ok da

Test #24:

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

input:

4
3 1 2 4

output:

2
3 4
1 2

result:

ok da

Test #25:

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

input:

4
3 1 4 2

output:

2
3 4
1 2

result:

ok da

Test #26:

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

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: 6108kb

input:

4
3 2 4 1

output:

3
3 4
2 2
1 1

result:

ok da

Test #28:

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

input:

4
3 4 1 2

output:

2
3 4
1 2

result:

ok da

Test #29:

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

input:

4
3 4 2 1

output:

3
3 4
2 2
1 1

result:

ok da

Test #30:

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

input:

4
4 1 2 3

output:

3
4 4
1 2
3 3

result:

ok da

Test #31:

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

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: 6600kb

input:

4
4 2 1 3

output:

3
4 4
2 3
1 1

result:

ok da

Test #33:

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

input:

4
4 2 3 1

output:

3
4 4
2 3
1 1

result:

ok da

Test #34:

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

input:

4
4 3 1 2

output:

3
4 4
3 3
1 2

result:

ok da

Test #35:

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

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: 6168kb

input:

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

output:

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

result:

ok da

Test #37:

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

input:

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

output:

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

result:

ok da

Test #38:

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

input:

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

output:

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

result:

ok da

Test #39:

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

input:

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

output:

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

result:

ok da

Test #40:

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

input:

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

output:

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

result:

ok da

Test #41:

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

input:

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

output:

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

result:

ok da

Test #42:

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

input:

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

output:

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

result:

ok da

Test #43:

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

input:

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

output:

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

result:

ok da

Test #44:

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

input:

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

output:

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

result:

ok da

Test #45:

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

input:

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

output:

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

result:

ok da

Test #46:

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

input:

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

output:

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

result:

ok da

Test #47:

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

input:

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

output:

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

result:

ok da

Test #48:

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

input:

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

output:

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

result:

ok da

Test #49:

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

input:

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

output:

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

result:

ok da

Test #50:

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

input:

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

output:

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

result:

ok da

Test #51:

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

input:

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

output:

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

result:

ok da

Test #52:

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

input:

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

output:

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

result:

ok da

Test #53:

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

input:

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

output:

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

result:

ok da

Test #54:

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

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
237 345
454 492
494 495
201 357
442 488
489 490
491 493
155 300
431 450
478 485
486 487
129 295
343 393
402 409
449 475
476 477
483 484
113 198
288 316
384 386
395 418
430 465
473 480
482 11
14 79
285 293
296 328
336 373
375 416
427 468
471 472
474 481
64 101
128 249
315 320
326 355
363 412
415 ...

result:

ok da

Test #55:

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

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

result:

ok da

Test #56:

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

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
5 6
7 9
10 12
13 15
17 18
19 20
24 26
27 29
30 31
33 34
35 39
40 43
44 47
48 53
56 57
60 62
63 65
69 71
72 74
77 80
81 84
87 88
89 90
92 96
97 98
99 102
105 106
110 111
112 114
119 120
123 126
127 129
132 133
136 137
143 144
150 151
152 154
156 157
158 160
162 163
167 169
173 174
178 180
183 195...

result:

ok da

Test #57:

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

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
237 345
454 492
496 201
357 442
488 489
490 491
494 495
155 300
431 450
478 485
486 487
493 129
295 343
393 402
409 449
475 476
477 483
484 113
198 288
316 384
386 395
418 465
473 480
482 11
14 79
285 293
296 328
336 373
375 416
427 468
471 472
474 481
64 101
128 249
315 320
326 355
363 412
415 ...

result:

ok da

Test #58:

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

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

result:

ok da

Test #59:

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

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
5 6
8 9
11 13
14 16
19 21
24 26
29 31
32 33
35 39
41 44
47 48
51 54
55 56
58 59
60 67
68 70
74 75
76 77
81 83
85 86
88 89
90 92
94 96
100 101
104 107
110 111
112 113
116 119
121 122
123 127
128 129
130 131
133 134
136 138
139 140
142 143
147 148
149 152
156 161
162 164
165 166
168 173
174 175
17...

result:

ok da

Test #60:

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

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
237 345
454 492
496 497
201 357
442 488
489 490
491 494
495 155
300 431
450 478
485 486
487 493
129 295
343 393
402 409
449 475
476 477
483 484
113 198
288 316
384 386
395 418
465 473
480 482
11 14
79 285
293 296
328 336
373 375
416 427
468 471
472 474
481 64
101 128
249 315
320 326
355 363
412 ...

result:

ok da

Test #61:

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

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

result:

ok da

Test #62:

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

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
6 10
11 12
15 16
17 18
19 21
25 26
30 31
32 33
35 37
40 41
43 45
46 49
50 52
53 54
58 59
61 63
67 68
69 72
77 78
79 80
82 85
87 88
89 91
98 102
104 111
112 113
117 118
120 125
129 130
131 133
143 147
148 149
150 151
152 153
154 155
156 157
158 162
163 164
168 169
170 171
172 173
178 180
181 182
...

result:

ok da

Test #63:

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

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:

249
237 345
454 492
496 498
201 357
442 488
489 490
491 494
497 155
300 431
450 478
485 486
487 495
129 295
343 393
402 409
449 475
476 477
483 484
493 113
198 288
316 384
386 395
418 465
473 480
482 11
14 79
285 293
296 328
336 373
375 416
427 468
471 472
474 481
64 101
128 249
315 320
326 355
363 ...

result:

ok da

Test #64:

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

input:

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

output:

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

result:

ok da

Test #65:

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

input:

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

output:

249
2 8
10 11
12 15
17 21
22 24
27 28
31 32
35 40
42 47
50 51
52 53
54 55
56 59
61 63
65 67
69 70
72 75
76 80
81 84
85 88
89 91
93 94
97 98
99 100
102 103
105 107
110 112
113 117
118 119
121 123
125 130
133 134
137 141
142 144
145 147
149 154
156 159
161 163
164 165
168 169
172 173
174 175
176 177
1...

result:

ok da

Test #66:

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

input:

499
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
237 345
454 492
496 498
499 201
357 442
488 489
490 491
494 497
155 300
431 450
478 485
486 487
495 129
295 343
393 402
409 449
475 476
477 483
484 493
113 198
288 316
384 386
395 418
465 473
480 482
11 14
79 285
293 296
328 336
373 375
416 427
468 471
472 474
481 64
101 128
249 315
320 326
355 ...

result:

ok da

Test #67:

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

input:

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

output:

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

result:

ok da

Test #68:

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

input:

499
5 7 11 12 13 1 17 18 20 22 24 2 3 25 26 27 4 29 31 6 32 33 8 9 10 14 15 34 35 16 19 21 23 28 41 30 36 37 42 45 38 39 46 49 40 50 51 43 52 44 47 48 54 59 53 65 55 67 68 71 56 57 74 75 78 79 58 81 86 87 88 89 60 91 61 98 99 100 102 103 112 62 113 63 114 64 115 116 66 117 69 120 70 121 72 122 124 7...

output:

250
5 7
11 12
13 17
18 20
22 24
25 26
27 29
31 32
33 34
35 41
42 45
46 49
50 51
52 54
59 65
67 68
71 74
75 78
79 81
86 87
88 89
91 98
99 100
102 103
112 113
114 115
116 117
120 121
122 124
125 128
130 133
137 143
144 145
153 155
159 160
161 162
163 164
166 168
169 174
176 178
182 186
189 190
191 194...

result:

ok da

Test #69:

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

input:

500
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
237 345
454 492
496 500
201 357
442 488
489 490
491 494
498 499
155 300
431 450
478 485
486 497
129 295
343 393
402 409
449 475
476 477
483 484
487 495
113 198
288 316
384 386
395 418
465 473
480 482
493 11
14 79
285 293
296 328
336 373
375 416
427 468
471 472
474 481
64 101
128 249
315 320
326 ...

result:

ok da

Test #70:

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

input:

500
499 500 495 490 498 489 497 496 488 486 484 482 478 477 476 475 494 493 470 492 491 469 468 467 487 463 458 485 483 481 450 444 442 480 479 441 474 473 472 440 439 438 437 471 436 435 466 434 430 465 429 428 425 424 423 464 422 421 462 461 460 459 419 417 415 457 413 456 455 454 453 452 411 410 ...

output:

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

result:

ok da

Test #71:

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

input:

500
1 4 10 12 13 15 17 18 2 20 23 27 3 28 29 5 30 6 7 8 9 11 31 33 14 35 16 36 37 38 39 19 40 42 21 48 49 53 55 56 58 59 60 22 24 62 63 65 25 66 69 26 32 71 75 34 41 78 79 81 82 83 86 43 44 88 90 45 46 47 91 92 50 51 93 52 94 97 98 99 54 100 101 57 61 102 104 105 108 64 109 67 110 68 70 112 72 113 1...

output:

250
4 10
12 13
15 17
18 20
23 27
28 29
30 31
33 35
36 37
38 39
40 42
48 49
53 55
56 58
59 60
62 63
65 66
69 71
75 78
79 81
82 83
86 88
90 91
92 93
94 97
98 99
100 101
102 104
105 108
109 110
112 113
115 118
120 121
127 133
138 139
140 146
147 149
153 155
156 157
158 159
160 161
162 165
166 168
173 1...

result:

ok da

Test #72:

score: 0
Accepted
time: 90ms
memory: 77576kb

input:

7495
4964 650 6871 129 3768 1551 6223 3875 6536 6438 5015 2528 1952 6441 3809 5102 4857 1821 343 4675 5029 7078 5456 3073 5001 5755 7275 3342 384 1608 1397 4856 1282 6194 878 4679 3536 6512 520 5397 2350 3380 1127 3969 2691 227 7293 3378 2728 3182 4059 6851 6641 900 2747 7195 4531 165 6187 4029 522 ...

output:

3748
4964 6871
7078 7275
7293 7396
7459 7485
7495 650
3768 6223
6536 6851
7195 7328
7343 7365
7415 7443
7466 7469
7491 7494
129 1551
3875 6438
6441 6512
6641 6858
7065 7216
7360 7362
7404 7447
7464 7468
7486 7492
7493 5015
5102 5456
5755 6194
6704 7136
7168 7182
7226 7285
7324 7341
7363 7397
7463 74...

result:

ok da

Test #73:

score: 0
Accepted
time: 79ms
memory: 136500kb

input:

7495
7495 7490 7488 7486 7494 7481 7480 7478 7477 7475 7463 7460 7459 7493 7492 7458 7491 7489 7487 7485 7457 7455 7484 7483 7454 7453 7452 7450 7448 7482 7444 7442 7440 7435 7479 7431 7476 7474 7426 7473 7423 7422 7421 7418 7472 7471 7470 7469 7468 7467 7414 7413 7411 7409 7408 7405 7466 7465 7403 ...

output:

3773
7495 7495
7490 7494
7488 7493
7486 7492
7481 7491
7480 7489
7478 7487
7477 7485
7475 7484
7463 7483
7460 7482
7459 7479
7458 7476
7457 7474
7455 7473
7454 7472
7453 7471
7452 7470
7450 7469
7448 7468
7444 7467
7442 7466
7440 7465
7435 7464
7431 7462
7426 7461
7423 7456
7422 7451
7421 7449
7418 ...

result:

ok da

Test #74:

score: 0
Accepted
time: 17ms
memory: 8020kb

input:

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

output:

3748
3 5
7 8
10 11
13 14
17 21
23 25
26 31
32 35
36 37
42 45
46 47
48 49
51 52
58 60
62 63
64 65
66 70
72 73
74 75
77 78
79 81
82 83
87 88
89 93
97 100
102 107
108 110
112 113
118 119
120 124
125 128
129 131
133 134
135 137
138 140
142 146
149 150
151 152
153 155
157 160
161 164
166 167
170 173
177 ...

result:

ok da

Test #75:

score: 0
Accepted
time: 97ms
memory: 77544kb

input:

7496
4964 650 6871 129 3768 1551 6223 3875 6536 6438 5015 2528 1952 6441 3809 5102 4857 1821 343 4675 5029 7078 5456 3073 5001 5755 7275 3342 384 1608 1397 4856 1282 6194 878 4679 3536 6512 520 5397 2350 3380 1127 3969 2691 227 7293 3378 2728 3182 4059 6851 6641 900 2747 7195 4531 165 6187 4029 522 ...

output:

3748
4964 6871
7078 7275
7293 7396
7459 7485
7495 7496
650 3768
6223 6536
6851 7195
7328 7343
7365 7415
7443 7466
7469 7491
7494 129
1551 3875
6438 6441
6512 6641
6858 7065
7216 7360
7362 7404
7447 7464
7468 7486
7492 7493
5015 5102
5456 5755
6194 6704
7136 7168
7182 7226
7285 7324
7341 7363
7397 74...

result:

ok da

Test #76:

score: 0
Accepted
time: 87ms
memory: 136724kb

input:

7496
7493 7496 7495 7490 7494 7489 7492 7491 7484 7476 7488 7487 7473 7471 7470 7468 7467 7465 7462 7456 7486 7455 7453 7451 7485 7446 7483 7482 7481 7480 7479 7478 7477 7445 7444 7475 7439 7435 7474 7472 7433 7432 7469 7430 7429 7428 7466 7464 7463 7427 7461 7460 7423 7422 7420 7459 7458 7418 7415 ...

output:

3779
7493 7496
7495 7495
7490 7494
7489 7492
7491 7491
7484 7488
7476 7487
7473 7486
7471 7485
7470 7483
7468 7482
7467 7481
7465 7480
7462 7479
7456 7478
7455 7477
7453 7475
7451 7474
7446 7472
7445 7469
7444 7466
7439 7464
7435 7463
7433 7461
7432 7460
7430 7459
7429 7458
7428 7457
7427 7454
7423 ...

result:

ok da

Test #77:

score: 0
Accepted
time: 17ms
memory: 7928kb

input:

7496
4 8 9 14 16 1 19 2 3 5 6 20 21 23 7 25 32 10 33 34 35 36 38 11 39 12 40 13 15 17 43 45 46 47 18 48 51 54 22 58 61 24 62 67 68 26 27 28 72 29 73 75 76 80 30 81 31 37 41 42 82 83 44 85 49 87 50 91 100 52 53 55 56 57 101 103 104 105 106 59 107 109 112 60 63 64 114 122 65 124 66 126 69 70 71 74 127...

output:

3748
4 8
9 14
16 19
20 21
23 25
32 33
34 35
36 38
39 40
43 45
46 47
48 51
54 58
61 62
67 68
72 73
75 76
80 81
82 83
85 87
91 100
101 103
104 105
106 107
109 112
114 122
124 126
127 129
131 139
142 143
146 147
151 152
153 155
156 159
160 161
163 165
166 167
168 169
171 177
180 181
182 185
187 188
190...

result:

ok da

Test #78:

score: 0
Accepted
time: 113ms
memory: 77600kb

input:

7497
4964 650 6871 129 3768 1551 6223 3875 6536 6438 5015 2528 1952 6441 3809 5102 4857 1821 343 4675 5029 7078 5456 3073 5001 5755 7275 3342 384 1608 1397 4856 1282 6194 878 4679 3536 6512 520 5397 2350 3380 1127 3969 2691 227 7293 3378 2728 3182 4059 6851 6641 900 2747 7195 4531 165 6187 4029 522 ...

output:

3749
4964 6871
7078 7275
7293 7396
7459 7485
7495 7497
650 3768
6223 6536
6851 7195
7328 7343
7365 7415
7443 7466
7469 7491
7494 7496
129 1551
3875 6438
6441 6512
6641 6858
7065 7216
7360 7362
7404 7447
7464 7468
7486 7492
7493 5015
5102 5456
5755 6194
6704 7136
7168 7182
7226 7285
7324 7341
7363 73...

result:

ok da

Test #79:

score: 0
Accepted
time: 75ms
memory: 137744kb

input:

7497
7493 7490 7489 7488 7487 7486 7497 7485 7496 7482 7495 7481 7480 7479 7478 7494 7492 7477 7470 7491 7469 7484 7483 7476 7468 7475 7466 7462 7474 7461 7473 7458 7457 7455 7472 7454 7453 7450 7447 7471 7445 7467 7465 7444 7464 7443 7442 7440 7463 7439 7460 7459 7438 7437 7435 7430 7456 7452 7427 ...

output:

3790
7493 7497
7490 7496
7489 7495
7488 7494
7487 7492
7486 7491
7485 7485
7482 7484
7481 7483
7480 7480
7479 7479
7478 7478
7477 7477
7470 7476
7469 7475
7468 7474
7466 7473
7462 7472
7461 7471
7458 7467
7457 7465
7455 7464
7454 7463
7453 7460
7450 7459
7447 7456
7445 7452
7444 7451
7443 7449
7442 ...

result:

ok da

Test #80:

score: 0
Accepted
time: 17ms
memory: 8064kb

input:

7497
4 1 7 11 14 15 18 22 2 23 3 5 26 34 35 6 8 36 38 9 10 12 13 39 40 43 44 45 16 17 47 48 49 19 50 57 59 60 20 21 24 25 62 27 28 64 67 68 29 30 31 71 76 77 79 32 81 33 82 84 85 86 87 88 37 41 90 92 93 95 42 96 97 103 105 46 51 52 53 107 108 109 110 54 55 111 112 113 56 115 58 61 63 117 65 118 119 ...

output:

3749
4 7
11 14
15 18
22 23
26 34
35 36
38 39
40 43
44 45
47 48
49 50
57 59
60 62
64 67
68 71
76 77
79 81
82 84
85 86
87 88
90 92
93 95
96 97
103 105
107 108
109 110
111 112
113 115
117 118
119 122
124 125
127 128
130 131
132 134
135 136
138 143
145 146
147 149
150 151
152 153
154 155
158 159
168 172...

result:

ok da

Test #81:

score: 0
Accepted
time: 110ms
memory: 77528kb

input:

7498
4964 650 6871 129 3768 1551 6223 3875 6536 6438 5015 2528 1952 6441 3809 5102 4857 1821 343 4675 5029 7078 5456 3073 5001 5755 7275 3342 384 1608 1397 4856 1282 6194 878 4679 3536 6512 520 5397 2350 3380 1127 3969 2691 227 7293 3378 2728 3182 4059 6851 6641 900 2747 7195 4531 165 6187 4029 522 ...

output:

3749
4964 6871
7078 7275
7293 7396
7459 7485
7495 7497
7498 650
3768 6223
6536 6851
7195 7328
7343 7365
7415 7443
7466 7469
7491 7494
7496 129
1551 3875
6438 6441
6512 6641
6858 7065
7216 7360
7362 7404
7447 7464
7468 7486
7492 7493
5015 5102
5456 5755
6194 6704
7136 7168
7182 7226
7285 7324
7341 73...

result:

ok da

Test #82:

score: 0
Accepted
time: 82ms
memory: 136932kb

input:

7498
7495 7494 7492 7488 7498 7497 7487 7486 7485 7496 7484 7483 7493 7491 7482 7490 7480 7489 7478 7477 7473 7472 7469 7481 7465 7464 7479 7476 7475 7463 7462 7459 7458 7474 7457 7456 7471 7470 7454 7452 7450 7447 7446 7468 7467 7444 7443 7439 7466 7438 7461 7437 7460 7455 7435 7434 7453 7433 7431 ...

output:

3768
7495 7498
7494 7497
7492 7496
7488 7493
7487 7491
7486 7490
7485 7489
7484 7484
7483 7483
7482 7482
7480 7481
7478 7479
7477 7477
7473 7476
7472 7475
7469 7474
7465 7471
7464 7470
7463 7468
7462 7467
7459 7466
7458 7461
7457 7460
7456 7456
7454 7455
7452 7453
7450 7451
7447 7449
7446 7448
7444 ...

result:

ok da

Test #83:

score: 0
Accepted
time: 17ms
memory: 8124kb

input:

7498
4 5 6 1 9 2 3 7 8 13 10 16 17 20 21 25 11 26 28 12 14 15 18 19 22 23 24 30 31 27 33 29 32 39 48 34 35 49 36 51 37 54 38 40 55 41 56 42 43 57 58 59 44 61 64 65 45 71 46 47 50 52 72 53 73 77 78 60 62 88 92 93 63 66 95 99 67 68 100 69 70 74 75 101 76 79 102 103 106 80 81 109 115 116 117 82 120 124...

output:

3749
4 5
6 9
13 16
17 20
21 25
26 28
30 31
33 39
48 49
51 54
55 56
57 58
59 61
64 65
71 72
73 77
78 88
92 93
95 99
100 101
102 103
106 109
115 116
117 120
124 125
127 131
133 134
135 139
141 143
144 146
148 149
151 153
154 155
156 158
160 163
164 165
166 169
170 172
173 175
177 181
182 183
184 185
1...

result:

ok da

Test #84:

score: 0
Accepted
time: 106ms
memory: 78168kb

input:

7499
4964 650 6871 129 3768 1551 6223 3875 6536 6438 5015 2528 1952 6441 3809 5102 4857 1821 343 4675 5029 7078 5456 3073 5001 5755 7275 3342 384 1608 1397 4856 1282 6194 878 4679 3536 6512 520 5397 2350 3380 1127 3969 2691 227 7293 3378 2728 3182 4059 6851 6641 900 2747 7195 4531 165 6187 4029 522 ...

output:

3750
4964 6871
7078 7275
7293 7396
7459 7485
7495 7497
7499 650
3768 6223
6536 6851
7195 7328
7343 7365
7415 7443
7466 7469
7491 7494
7498 129
1551 3875
6438 6441
6512 6641
6858 7065
7216 7360
7362 7404
7447 7464
7468 7486
7492 7496
5015 5102
5456 5755
6194 6704
7136 7168
7182 7226
7285 7324
7341 73...

result:

ok da

Test #85:

score: 0
Accepted
time: 91ms
memory: 137292kb

input:

7499
7498 7499 7491 7497 7496 7487 7495 7494 7485 7481 7479 7493 7492 7490 7489 7477 7488 7476 7471 7486 7470 7484 7464 7483 7463 7482 7460 7480 7459 7478 7475 7454 7452 7474 7473 7472 7451 7450 7449 7448 7446 7469 7468 7467 7466 7465 7443 7462 7438 7461 7458 7457 7456 7428 7455 7426 7425 7424 7423 ...

output:

3766
7498 7499
7491 7497
7496 7496
7487 7495
7494 7494
7485 7493
7481 7492
7479 7490
7489 7489
7477 7488
7476 7486
7471 7484
7470 7483
7464 7482
7463 7480
7460 7478
7459 7475
7454 7474
7452 7473
7472 7472
7451 7469
7450 7468
7449 7467
7448 7466
7446 7465
7443 7462
7438 7461
7458 7458
7457 7457
7456 ...

result:

ok da

Test #86:

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

input:

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

output:

3750
2 3
5 8
14 20
22 23
25 26
34 38
39 40
41 44
45 46
51 53
54 59
61 62
63 64
65 66
67 68
69 72
73 74
80 83
85 87
88 89
90 92
93 97
101 102
103 105
106 109
111 112
113 116
117 118
119 122
123 125
126 130
132 133
134 135
136 137
139 140
143 145
147 149
151 152
154 155
157 160
162 163
164 165
171 177...

result:

ok da

Test #87:

score: 0
Accepted
time: 110ms
memory: 77928kb

input:

7500
4964 650 6871 129 3768 1551 6223 3875 6536 6438 5015 2528 1952 6441 3809 5102 4857 1821 343 4675 5029 7078 5456 3073 5001 5755 7275 3342 384 1608 1397 4856 1282 6194 878 4679 3536 6512 520 5397 2350 3380 1127 3969 2691 227 7293 3378 2728 3182 4059 6851 6641 900 2747 7195 4531 165 6187 4029 522 ...

output:

3750
4964 6871
7078 7275
7293 7396
7459 7485
7495 7497
7499 7500
650 3768
6223 6536
6851 7195
7328 7343
7365 7415
7443 7466
7469 7491
7494 7498
129 1551
3875 6438
6441 6512
6641 6858
7065 7216
7360 7362
7404 7447
7464 7468
7486 7492
7496 5015
5102 5456
5755 6194
6704 7136
7168 7182
7226 7285
7324 73...

result:

ok da

Test #88:

score: 0
Accepted
time: 70ms
memory: 137024kb

input:

7500
7500 7498 7499 7497 7492 7490 7488 7485 7481 7479 7476 7471 7496 7470 7469 7495 7494 7466 7493 7491 7460 7489 7459 7458 7456 7455 7487 7453 7486 7450 7447 7484 7446 7443 7440 7436 7435 7483 7482 7430 7424 7423 7422 7480 7421 7478 7418 7416 7477 7413 7475 7411 7474 7473 7472 7468 7410 7467 7408 ...

output:

3788
7500 7500
7498 7499
7497 7497
7492 7496
7490 7495
7488 7494
7485 7493
7481 7491
7479 7489
7476 7487
7471 7486
7470 7484
7469 7483
7466 7482
7460 7480
7459 7478
7458 7477
7456 7475
7455 7474
7453 7473
7450 7472
7447 7468
7446 7467
7443 7465
7440 7464
7436 7463
7435 7462
7430 7461
7424 7457
7423 ...

result:

ok da

Test #89:

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

input:

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

output:

3750
4 6
14 16
17 18
21 22
23 24
27 31
32 35
39 40
41 42
44 49
52 54
55 58
59 61
62 67
68 69
72 73
74 75
76 80
82 84
85 88
91 93
94 95
97 98
99 102
107 108
109 112
113 116
117 118
124 125
132 134
136 140
141 144
146 147
148 150
152 153
157 159
161 163
168 170
171 172
174 176
178 179
180 182
184 185
...

result:

ok da

Test #90:

score: -100
Time Limit Exceeded

input:

99995
64268 66535 9758 42907 84212 83488 27748 86198 80658 11614 93419 2528 96160 79473 83517 43109 37111 46603 93665 54540 84236 62717 24719 57225 8333 15728 40821 31719 13096 75018 76890 46244 75863 59618 67460 10326 84775 11276 83363 72071 9353 94316 9469 3969 78568 53071 96835 50125 2728 46756 5...

output:


result: