QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#297916#4088. 총 쏘기C1942huangjiaxu21 3824ms4064kbC++142.0kb2024-01-05 13:29:582024-01-05 13:29:58

Judging History

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

  • [2024-01-05 13:29:58]
  • 评测
  • 测评结果:21
  • 用时:3824ms
  • 内存:4064kb
  • [2024-01-05 13:29:58]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
mt19937 rnd(time(0));
int n,f[N],a[N],ct,p[N],T=30;
bool out[N],dl[N];
vector<pair<int,int> > calc(){
	ct=0;
	for(int i=1;i<=n;++i)out[i]=dl[i]=p[i]=0;
	for(int i=1;i<=n;++i){
		if(rnd()%n+1<=a[i])continue;
		int mx=0;
		for(int j=1;j<i;++j)if(!p[j]&&a[j]<a[i]){
			if(a[j]>a[mx])mx=j;
		}
		if(mx){
			p[mx]=i,p[i]=mx;
			continue;
		}
		for(int j=1;j<i;++j)if(p[j]<j&&a[j]<a[i]){
			p[p[j]]=0,p[j]=i,p[i]=j;
			break;
		}
	}
	for(int i=1;i<=n;++i)if(!p[i]){
		int mx=0;
		for(int j=1;j<i;++j)if(!p[j]&&a[j]<a[i]){
			if(a[j]>a[mx])mx=j;
		}
		if(mx){
			p[mx]=i,p[i]=mx;
			continue;
		}
		for(int j=1;j<i;++j)if(p[j]<j&&a[j]<a[i]){
			p[p[j]]=0,p[j]=i,p[i]=j;
			break;
		}
	}
	vector<pair<int,int> >ans;
	while(ct<n){
		int mx=0;
		for(int i=1;i<=n;++i)out[i]=false;
		for(int i=1;i<=n;++i)if(!dl[i]){
			mx=max(mx,a[i]);
			if(mx==a[i])out[i]=true;
		}
		bool fg=false;
		for(int i=1;i<=n;++i)if(out[i]&&!p[i]){
			ans.push_back(make_pair(a[i],a[i]));
			dl[i]=true;
			fg=true;
			break;
		}
		if(fg){
			++ct;
			continue;
		}
		for(int i=n,ls=0;i;--i)if(out[i]){
			if(out[p[i]]){
				ans.push_back(make_pair(a[i],a[p[i]]));
				dl[i]=dl[p[i]]=true;
				ct+=2;
				break;
			}else if(p[i]>i){
				p[p[i]]=p[ls];
				p[p[ls]]=p[i];
				ans.push_back(make_pair(a[i],a[ls]));
				dl[i]=dl[ls]=true;
				ct+=2;
				break;
			}
			ls=i;
		}
	}
	return ans;
}
vector<pair<int, int> > min_shooting_buildings(vector<int> H){
	n=H.size();
	for(int i=1;i<=n;++i){
		a[i]=H[i-1];
		int mx=0;
		for(int j=1;j<i;++j)if(!p[j]&&a[j]<a[i]){
			if(a[j]>a[mx])mx=j;
		}
		if(mx){
			p[mx]=i,p[i]=mx;
			continue;
		}
		for(int j=1;j<i;++j)if(p[j]<j&&a[j]<a[i]){
			p[p[j]]=0,p[j]=i,p[i]=j;
			break;
		}
	}
	vector<pair<int,int> >ans=calc();
	while(T--){
		vector<pair<int,int> >tmp=calc();
		if(tmp.size()<ans.size())ans=tmp;
	}
	return ans;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 17
Accepted
time: 1ms
memory: 3768kb

input:

8
4 3 8 2 1 7 6 5

output:

4
4 8
3 7
2 6
5 1

result:

ok Correct

Test #2:

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

input:

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

output:

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

result:

ok Correct

Test #3:

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

input:

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

output:

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

result:

ok Correct

Test #4:

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

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
11 7
9 9
6 6
5 4
3 1
2 2

result:

ok Correct

Test #5:

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

input:

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

output:

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

result:

ok Correct

Test #6:

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

input:

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

output:

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

result:

ok Correct

Test #7:

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

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
3 2
1 1

result:

ok Correct

Test #8:

score: -17
Wrong Answer
time: 13ms
memory: 3780kb

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:

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

result:

wrong answer Incorrect

Subtask #2:

score: 0
Time Limit Exceeded

Test #26:

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

input:

8
5 6 7 1 2 8 3 4

output:

4
8 5
7 6
4 1
3 2

result:

ok Correct

Test #27:

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

input:

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

output:

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

result:

ok Correct

Test #28:

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

input:

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

output:

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

result:

ok Correct

Test #29:

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

input:

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

output:

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

result:

ok Correct

Test #30:

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

input:

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

output:

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

result:

ok Correct

Test #31:

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

input:

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

output:

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

result:

ok Correct

Test #32:

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

input:

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

output:

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

result:

ok Correct

Test #33:

score: 0
Accepted
time: 13ms
memory: 3832kb

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
62 62
490 152
489 487
486 485
482 154
481 60
480 156
476 150
470 137
469 9
460 133
458 457
455 53
454 127
452 123
447 456
446 126
444 112
443 13
436 111
433 432
430 48
426 105
424 26
422 421
409 102
408 407
405 397
399 398
392 98
391 96
390 24
389 383
381 90
380 379
378 376
374 84
373 87
372 353...

result:

ok Correct

Test #34:

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

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
493 147
489 143
487 33
482 138
480 58
478 484
476 32
475 134
472 56
469 133
463 1
462 131
461 130
459 31
456 128
455 14
450 29
448 8
445 449
442 452
436 113
435 54
433 24
427 5
421 417
416 415
414 104
413 107
410 101
408 424
406 429
404 51
403 399
396 96
394 92
393 94
392 21
391 90
389 386
379 1...

result:

ok Correct

Test #35:

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

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
494 178
488 486
482 169
478 11
475 168
473 163
472 164
465 464
463 162
458 32
457 157
456 156
453 154
452 153
449 148
447 149
440 133
439 143
437 443
433 6
495 2
432 131
429 30
427 430
424 431
416 53
414 130
413 12
412 129
410 118
401 117
400 397
394 50
392 112
389 111
386 385
384 91
383 98
376 ...

result:

ok Correct

Test #36:

score: 0
Accepted
time: 13ms
memory: 3780kb

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
498 173
497 174
493 169
491 165
490 168
488 149
487 159
486 154
485 147
484 40
482 481
480 494
478 35
477 72
476 164
475 10
474 473
470 472
469 123
468 156
467 125
466 145
464 75
455 67
444 118
443 61
440 117
432 441
429 28
427 112
424 59
423 419
418 107
417 110
410 54
407 27
405 411
403 102
399...

result:

ok Correct

Test #37:

score: 0
Accepted
time: 13ms
memory: 3836kb

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 5
499 199
495 22
494 194
493 71
490 191
485 189
478 34
474 176
471 178
470 174
469 163
468 168
465 164
463 166
459 59
453 54
450 161
449 162
446 33
442 159
441 155
439 20
432 125
430 130
428 18
426 50
425 31
421 29
415 46
414 413
408 412
406 402
405 404
397 389
386 17
384 383
381 26
380 377
37...

result:

ok Correct

Test #38:

score: 0
Accepted
time: 13ms
memory: 3784kb

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
500 81
499 181
494 174
489 4
486 168
482 165
480 33
475 162
474 161
473 160
472 31
471 158
468 17
464 30
461 147
455 66
451 450
449 140
448 15
441 445
439 133
438 65
437 29
436 435
425 427
421 420
417 60
414 10
410 409
407 422
404 59
403 115
400 27
397 113
395 58
393 110
392 56
390 385
374 370
3...

result:

ok Correct

Test #39:

score: 0
Accepted
time: 3822ms
memory: 3988kb

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
488 488
7494 485
7491 2357
7489 2356
7486 2352
7485 31
7484 937
7475 2343
7474 936
7465 119
7456 482
7455 2338
7441 2328
7440 2325
7439 2327
7435 2316
7430 2308
7428 2304
7427 2302
7421 2301
7408 2297
7405 2295
7402 2288
7396 2285
7395 921
7394 2283
7392 118
7378 2273
7376 2275
7373 476
7367 24...

result:

ok Correct

Test #40:

score: 0
Accepted
time: 3708ms
memory: 3936kb

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
7496 871
7495 410
7490 2349
7486 2344
7472 2342
7470 2341
7468 404
7467 2332
7463 2328
7462 2331
7455 208
7451 2311
7446 865
7438 19
7433 2285
7431 2286
7430 2287
7429 2299
7427 2293
7426 2294
7425 2291
7411 2284
7403 2273
7382 2262
7381 401
7378 2256
7373 857
7370 2245
7369 2243
7362 2223
7359...

result:

ok Correct

Test #41:

score: 0
Accepted
time: 3824ms
memory: 4064kb

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
7492 7491
7488 2334
7487 2330
7485 2326
7483 2324
7482 2320
7481 430
7479 2317
7475 220
7469 2308
7467 2312
7461 2311
7455 862
7451 865
7445 2304
7442 2297
7440 2286
7438 2294
7436 2280
7434 859
7428 844
7427 2273
7418 842
7417 2268
7410 2265
7409 2259
7401 2257
7396 2258
7394 839
7390 837
7389...

result:

ok Correct

Test #42:

score: 0
Accepted
time: 3765ms
memory: 3988kb

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
7495 2218
7494 2219
7493 2217
7490 825
7489 2212
7481 2206
7480 200
7478 2205
7471 2202
7470 2203
7468 7461
7460 2200
7457 2185
7455 2184
7453 2179
7452 2181
7451 823
7448 5
7447 2175
7446 2177
7443 2199
7440 822
7439 377
7437 2172
7434 7438
7424 2167
7423 820
7421 2163
7416 7420
7407 2159
7399...

result:

ok Correct

Test #43:

score: 0
Accepted
time: 3807ms
memory: 3976kb

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
207 207
7497 872
7496 2324
7493 870
7491 2319
7490 2317
7489 2318
7488 2315
7476 2312
7472 2308
7470 2307
7469 866
7460 111
7456 2293
7452 2297
7450 2291
7446 2289
7445 2282
7442 2283
7432 2279
7429 863
7417 2270
7409 859
7406 2256
7405 2259
7398 202
7396 857
7391 2248
7390 2250
7385 2240
7382 ...

result:

ok Correct

Test #44:

score: 0
Accepted
time: 3787ms
memory: 3988kb

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
7499 2302
7494 2291
7492 2289
7488 954
7481 2278
7479 2272
7477 949
7476 210
7475 2268
7470 211
7455 2261
7444 2251
7443 2248
7442 2247
7439 940
7433 2245
7429 2241
7428 938
7427 405
7422 937
7420 2237
7419 2236
7409 2201
7408 2228
7407 2225
7405 2222
7401 2220
7397 2218
7394 2219
7390 2205
738...

result:

ok Correct

Test #45:

score: -12
Time Limit Exceeded

input:

99995
4 5 6 8 10 1 11 2 3 14 16 19 21 7 22 9 24 26 27 12 29 31 35 43 13 47 15 17 48 18 51 20 23 25 28 52 53 55 30 56 58 32 60 61 33 34 36 63 37 38 64 65 39 66 70 40 72 77 86 88 89 41 42 44 45 46 91 49 93 94 95 98 100 50 101 54 102 103 57 59 62 67 104 108 68 112 116 117 118 119 69 120 71 73 74 123 12...

output:

Unauthorized output

result:


Subtask #3:

score: 9
Accepted

Test #51:

score: 9
Accepted
time: 1ms
memory: 3816kb

input:

1
1

output:

1
1 1

result:

ok Correct

Test #52:

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

input:

2
1 2

output:

1
2 1

result:

ok Correct

Test #53:

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

input:

2
2 1

output:

2
2 2
1 1

result:

ok Correct

Test #54:

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

input:

3
1 3 2

output:

2
3 3
2 1

result:

ok Correct

Test #55:

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

input:

3
2 1 3

output:

2
3 2
1 1

result:

ok Correct

Test #56:

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

input:

3
2 3 1

output:

2
3 2
1 1

result:

ok Correct

Test #57:

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

input:

3
3 1 2

output:

2
3 3
2 1

result:

ok Correct

Test #58:

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

input:

4
2 1 4 3

output:

2
4 2
3 1

result:

ok Correct

Test #59:

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

input:

4
2 4 1 3

output:

2
4 2
3 1

result:

ok Correct

Test #60:

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

input:

4
3 1 4 2

output:

2
4 3
2 1

result:

ok Correct

Test #61:

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

input:

4
3 4 1 2

output:

2
4 3
2 1

result:

ok Correct

Test #62:

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

input:

3
3 2 1

output:

3
3 3
2 2
1 1

result:

ok Correct

Test #63:

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

input:

4
1 4 3 2

output:

3
4 1
3 3
2 2

result:

ok Correct

Test #64:

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

input:

4
2 4 3 1

output:

3
4 2
3 3
1 1

result:

ok Correct

Test #65:

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

input:

4
3 2 1 4

output:

3
4 3
2 2
1 1

result:

ok Correct

Test #66:

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

input:

4
3 2 4 1

output:

3
4 3
2 2
1 1

result:

ok Correct

Test #67:

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

input:

4
3 4 2 1

output:

3
4 3
2 2
1 1

result:

ok Correct

Test #68:

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

input:

4
4 1 3 2

output:

3
4 4
3 1
2 2

result:

ok Correct

Test #69:

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

input:

4
4 2 1 3

output:

3
4 4
3 2
1 1

result:

ok Correct

Test #70:

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

input:

4
4 2 3 1

output:

3
4 4
3 2
1 1

result:

ok Correct

Test #71:

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

input:

4
4 3 1 2

output:

3
4 4
3 3
2 1

result:

ok Correct

Test #72:

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

input:

4
4 3 2 1

output:

4
4 4
3 3
2 2
1 1

result:

ok Correct

Test #73:

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

input:

3
1 2 3

output:

2
1 1
3 2

result:

ok Correct

Test #74:

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

input:

4
1 2 3 4

output:

2
4 1
3 2

result:

ok Correct

Test #75:

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

input:

4
1 2 4 3

output:

2
4 2
3 1

result:

ok Correct

Test #76:

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

input:

4
1 3 2 4

output:

2
3 1
4 2

result:

ok Correct

Test #77:

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

input:

4
1 3 4 2

output:

2
4 3
2 1

result:

ok Correct

Test #78:

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

input:

4
1 4 2 3

output:

2
4 1
3 2

result:

ok Correct

Test #79:

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

input:

4
2 1 3 4

output:

2
3 2
4 1

result:

ok Correct

Test #80:

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

input:

4
2 3 1 4

output:

2
3 2
4 1

result:

ok Correct

Test #81:

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

input:

4
2 3 4 1

output:

3
2 2
4 3
1 1

result:

ok Correct

Test #82:

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

input:

4
3 1 2 4

output:

2
4 3
2 1

result:

ok Correct

Test #83:

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

input:

4
4 1 2 3

output:

3
4 4
1 1
3 2

result:

ok Correct

Subtask #4:

score: 12
Accepted

Dependency #3:

100%
Accepted

Test #84:

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

input:

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

output:

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

result:

ok Correct

Test #85:

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

input:

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

output:

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

result:

ok Correct

Test #86:

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

input:

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

output:

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

result:

ok Correct

Test #87:

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

input:

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

output:

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

result:

ok Correct

Test #88:

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

input:

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

output:

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

result:

ok Correct

Test #89:

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

input:

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

output:

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

result:

ok Correct

Test #90:

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

input:

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

output:

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

result:

ok Correct

Test #91:

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

input:

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

output:

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

result:

ok Correct

Test #92:

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

input:

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

output:

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

result:

ok Correct

Test #93:

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

input:

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

output:

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

result:

ok Correct

Test #94:

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

input:

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

output:

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

result:

ok Correct

Test #95:

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

input:

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

output:

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

result:

ok Correct

Test #96:

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

input:

8
4 3 7 8 2 1 5 6

output:

4
7 4
8 3
5 2
6 1

result:

ok Correct

Test #97:

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

input:

9
1 6 5 8 9 4 3 2 7

output:

5
9 6
8 5
4 1
7 3
2 2

result:

ok Correct

Test #98:

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

input:

8
3 5 1 6 7 8 4 2

output:

4
8 5
7 6
4 3
2 1

result:

ok Correct

Subtask #5:

score: 0
Wrong Answer

Dependency #4:

100%
Accepted

Test #99:

score: 31
Accepted
time: 15ms
memory: 3776kb

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 492
454 488
489 357
478 490
450 491
475 494
476 485
473 486
465 468
457 449
442 471
431 448
483 402
470 418
462 409
430 452
427 456
423 441
421 429
416 425
415 434
412 455
403 397
395 451
393 399
487 392
391 477
390 436
388 484
458 480
386 401
384 428
382 375
379 385
374 377
373 383
370 424
...

result:

ok Correct

Test #100:

score: 0
Accepted
time: 11ms
memory: 3776kb

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
495 488
489 490
478 491
475 494
476 485
473 486
465 468
454 457
471 357
450 470
449 452
442 448
431 456
427 441
423 462
421 429
418 425
483 416
487 415
412 434
409 455
402 403
397 451
399 477
395 436
393 484
392 401
391 428
390 458
388 480
386 424
384 385
383 382
379 469
463 482
375 377
...

result:

ok Correct

Test #101:

score: 0
Accepted
time: 15ms
memory: 3836kb

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 492
490 237
488 201
454 489
478 491
450 496
495 475
449 494
487 476
473 485
468 486
483 465
442 457
431 471
470 418
456 416
427 448
423 452
441 393
421 462
429 434
415 425
412 455
409 451
403 477
402 436
399 397
395 484
392 401
391 428
390 458
388 480
386 424
385 384
382 379
377 375
374 383
...

result:

ok Correct

Test #102:

score: 0
Accepted
time: 15ms
memory: 3784kb

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
492 496
491 488
490 494
489 498
478 485
476 486
475 477
473 483
465 468
457 471
454 470
497 442
495 450
462 449
448 452
431 456
487 402
427 441
429 237
455 201
484 155
458 409
423 425
421 434
418 451
416 436
415 428
412 480
403 424
397 399
395 401
393 469
482 392
414 384
391 461
390 422
388 389
...

result:

ok Correct

Test #103:

score: 0
Accepted
time: 15ms
memory: 3820kb

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
499 492
454 488
450 489
478 490
449 449
442 491
431 496
498 409
497 237
475 494
487 476
486 357
465 473
468 485
471 418
457 470
462 477
427 448
423 452
421 456
455 402
441 416
415 429
425 412
403 434
397 451
395 399
393 483
436 484
428 384
392 401
391 458
390 480
469 201
388 424
386 414
382 373
...

result:

ok Correct

Test #104:

score: 0
Accepted
time: 18ms
memory: 3832kb

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
496 492
494 488
490 491
489 500
478 485
476 486
475 477
465 473
454 468
484 450
449 457
442 471
431 448
427 470
423 452
441 462
434 393
421 429
418 425
416 455
415 451
412 483
480 237
436 458
409 428
403 201
402 424
401 399
397 469
395 498
392 414
391 461
390 497
388 389
386 422
385 345
384 445
...

result:

ok Correct

Test #105:

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

input:

500
498 497 500 499 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 ...

output:

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

result:

ok Correct

Test #106:

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

input:

500
497 500 494 498 499 493 495 496 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 ...

output:

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

result:

ok Correct

Test #107:

score: 0
Accepted
time: 13ms
memory: 3840kb

input:

500
500 498 499 497 495 493 494 496 490 491 488 492 489 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 ...

output:

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

result:

ok Correct

Test #108:

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

input:

500
499 500 498 496 495 497 494 493 492 489 490 491 487 488 485 486 484 483 481 482 480 477 479 476 478 474 475 471 473 472 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 ...

output:

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

result:

ok Correct

Test #109:

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

input:

500
500 499 498 497 496 495 494 493 492 491 490 489 488 487 485 484 486 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 ...

output:

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

result:

ok Correct

Test #110:

score: 0
Accepted
time: 15ms
memory: 3892kb

input:

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

output:

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

result:

ok Correct

Test #111:

score: 0
Accepted
time: 10ms
memory: 3832kb

input:

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

output:

250
500 164
499 165
498 54
497 163
495 162
494 160
493 161
492 53
491 159
490 3
489 158
488 52
487 157
486 154
485 153
484 156
483 155
482 25
496 24
481 152
480 51
479 151
478 149
477 476
475 150
474 10
473 148
472 50
471 147
470 23
469 146
468 49
467 145
466 5
465 144
463 462
461 143
460 22
459 142...

result:

ok Correct

Test #112:

score: 0
Accepted
time: 14ms
memory: 3860kb

input:

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

output:

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

result:

ok Correct

Test #113:

score: -31
Wrong Answer
time: 13ms
memory: 3712kb

input:

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

output:

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

result:

wrong answer Incorrect

Subtask #6:

score: 0
Skipped

Dependency #5:

0%

Subtask #7:

score: 0
Skipped

Dependency #1:

0%