QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#763120 | #9623. 合成大西瓜 | lonelywolf# | AC ✓ | 20ms | 5964kb | C++20 | 1021b | 2024-11-19 18:16:02 | 2024-11-19 18:16:03 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
void solve() {
int n, m;
cin >> n >> m;
vector<int> a(n + 1), deg(n + 1);
for(int i = 1; i <= n; ++i)
cin >> a[i];
for(int i = 0; i < m; ++i) {
int u, v;
cin >> u >> v;
++deg[u];
++deg[v];
}
if(n == 1) {
cout << a[1] << "\n";
return ;
}
vector<int> x, y;
for(int i = 1; i <= n; ++i) {
if(deg[i] >= 2)
x.emplace_back(a[i]);
else
y.emplace_back(a[i]);
}
sort(x.begin(), x.end());
sort(y.begin(), y.end(), greater());
int ans = x.back();
if(y.size() >= 2)
ans = max(ans, y[1]);
cout << ans << '\n';
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
// cin >> t;
while (t--) {
solve();
}
return 0;
}
/*
7 7
1 1 2 3 1 2 1
1 2
2 3
1 3
2 4
2 5
5 6
5 7
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3556kb
input:
7 9 1 4 1 3 3 6 7 5 4 3 6 3 4 2 3 5 2 2 6 6 7 5 1 4 6
output:
6
result:
ok single line: '6'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
5 7 1 5 3 1 4 3 5 1 3 5 1 1 4 5 4 2 4 3 2
output:
5
result:
ok single line: '5'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3848kb
input:
7 7 2 4 2 3 3 6 7 5 1 2 6 5 3 4 6 1 6 1 2 2 7
output:
6
result:
ok single line: '6'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3652kb
input:
3 2 2 2 2 2 3 1 3
output:
2
result:
ok single line: '2'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3560kb
input:
5 5 3 1 2 4 5 3 2 2 4 3 5 5 1 2 5
output:
5
result:
ok single line: '5'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3784kb
input:
7 9 3 2 3 5 2 6 7 7 4 5 4 5 6 1 7 1 6 2 3 7 6 6 4 4 2
output:
7
result:
ok single line: '7'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3784kb
input:
3 2 1 2 3 3 1 2 1
output:
2
result:
ok single line: '2'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3820kb
input:
9 9 6 1 1 1 3 7 1 8 9 9 8 6 7 2 7 5 6 7 9 5 1 7 3 1 6 1 4
output:
9
result:
ok single line: '9'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
9 10 7 7 4 2 2 6 6 8 9 9 6 4 6 1 2 4 3 5 6 7 5 6 8 7 4 1 7 1 9
output:
9
result:
ok single line: '9'
Test #10:
score: 0
Accepted
time: 0ms
memory: 3560kb
input:
5 6 3 2 1 1 2 3 5 2 4 3 1 2 3 4 1 1 5
output:
3
result:
ok single line: '3'
Test #11:
score: 0
Accepted
time: 0ms
memory: 3864kb
input:
7 7 4 4 5 1 1 6 7 2 1 1 7 5 4 2 4 1 3 5 6 7 4
output:
7
result:
ok single line: '7'
Test #12:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
17 17 2 15 7 13 8 6 12 8 10 13 15 5 7 8 13 16 17 5 9 6 1 7 9 6 10 16 15 3 6 14 3 11 6 12 15 8 4 9 10 7 6 15 6 2 10 8 10 13 6 17 7
output:
16
result:
ok single line: '16'
Test #13:
score: 0
Accepted
time: 0ms
memory: 3632kb
input:
7 11 3 5 4 1 5 6 7 5 4 1 5 4 2 6 1 7 1 6 7 4 1 6 5 5 7 4 6 5 3
output:
7
result:
ok single line: '7'
Test #14:
score: 0
Accepted
time: 0ms
memory: 3848kb
input:
11 17 1 1 4 5 8 9 3 1 3 10 11 8 6 11 1 5 2 10 1 10 9 9 5 5 11 7 4 1 5 11 7 8 3 8 11 6 10 3 1 10 3 7 10 9 3
output:
11
result:
ok single line: '11'
Test #15:
score: 0
Accepted
time: 0ms
memory: 3632kb
input:
13 16 3 1 8 4 2 1 6 5 2 10 11 12 13 9 8 7 1 8 1 5 12 5 7 5 3 9 4 13 8 6 8 3 13 3 11 1 2 5 6 2 9 5 10 5 9
output:
13
result:
ok single line: '13'
Test #16:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
13 13 7 4 6 9 11 8 5 3 5 2 1 12 13 3 6 13 3 12 9 3 11 4 1 1 9 4 10 7 11 8 9 2 9 5 3 11 1 9 13
output:
13
result:
ok single line: '13'
Test #17:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
17 22 10 11 4 8 15 7 15 12 8 10 12 12 15 11 11 16 17 1 5 2 5 10 6 5 7 2 7 11 14 9 2 4 6 3 10 14 12 1 15 6 7 13 6 14 3 3 5 16 17 10 7 15 9 15 3 16 11 8 2 1 16
output:
16
result:
ok single line: '16'
Test #18:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
15 18 7 12 7 4 9 13 4 4 10 5 8 3 11 14 15 15 11 13 4 10 6 5 2 1 15 2 10 3 1 9 8 3 15 4 6 11 4 14 10 3 8 8 1 9 15 6 7 3 12 5 3
output:
15
result:
ok single line: '15'
Test #19:
score: 0
Accepted
time: 0ms
memory: 3560kb
input:
19 25 6 17 14 6 14 4 1 8 11 16 13 4 5 3 4 10 11 18 19 12 6 10 17 6 5 19 18 14 4 9 5 5 16 10 16 7 4 17 4 8 10 8 7 8 1 5 4 7 19 10 2 19 11 2 17 13 7 16 18 1 5 17 3 2 15 11 17 18 7
output:
19
result:
ok single line: '19'
Test #20:
score: 0
Accepted
time: 0ms
memory: 3504kb
input:
17 20 15 2 12 3 14 12 11 15 8 7 8 9 10 4 1 16 17 4 17 2 12 14 13 6 12 5 7 8 16 7 8 17 1 12 1 8 14 16 12 5 14 6 5 15 9 10 11 14 7 15 6 13 1 10 4 3 1
output:
17
result:
ok single line: '17'
Test #21:
score: 0
Accepted
time: 0ms
memory: 3664kb
input:
169 470 165 159 109 124 30 108 123 148 107 13 68 70 42 67 98 83 95 167 95 33 32 160 145 52 15 143 156 119 4 133 37 78 57 60 116 112 56 131 95 100 17 152 102 146 49 143 157 120 7 71 158 160 136 127 38 120 45 99 70 1 41 143 25 20 15 46 72 60 51 162 148 165 45 58 4 99 52 68 3 163 22 67 164 147 58 101 2...
output:
169
result:
ok single line: '169'
Test #22:
score: 0
Accepted
time: 0ms
memory: 3472kb
input:
503 611 454 67 371 273 211 385 410 328 360 360 40 239 10 95 124 294 249 162 130 15 454 486 114 390 84 369 260 410 64 246 205 114 383 458 33 134 299 154 439 417 265 19 215 73 292 6 165 331 349 63 371 233 295 145 269 158 95 76 274 299 143 445 437 37 216 88 58 75 74 391 326 401 320 46 433 464 456 336 1...
output:
503
result:
ok single line: '503'
Test #23:
score: 0
Accepted
time: 1ms
memory: 3584kb
input:
895 1110 171 465 600 50 134 163 661 892 838 1 698 337 341 719 732 328 799 271 438 145 809 611 425 362 688 877 38 317 693 491 148 814 10 557 155 855 681 65 589 321 382 697 671 510 217 315 634 765 112 870 625 508 731 299 722 660 773 221 110 249 190 373 796 799 253 82 614 776 518 338 156 799 87 304 562...
output:
895
result:
ok single line: '895'
Test #24:
score: 0
Accepted
time: 0ms
memory: 3848kb
input:
607 693 102 196 324 268 155 167 237 261 12 17 591 164 494 254 192 532 484 388 10 423 333 210 531 225 152 514 453 275 40 532 64 441 453 364 231 440 361 89 68 373 362 606 82 299 517 268 433 25 543 212 142 562 363 29 6 347 26 27 467 421 557 282 466 80 142 106 591 197 91 486 211 560 211 576 108 420 220 ...
output:
607
result:
ok single line: '607'
Test #25:
score: 0
Accepted
time: 0ms
memory: 3820kb
input:
739 1132 352 66 737 440 732 672 615 4 418 186 319 522 587 349 17 159 259 692 621 368 580 87 589 647 729 694 405 196 404 654 411 686 695 378 392 109 523 193 724 636 460 371 137 558 660 542 526 426 482 713 428 293 204 442 465 329 217 198 335 620 379 481 595 374 122 624 489 145 58 656 95 212 445 598 31...
output:
739
result:
ok single line: '739'
Test #26:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
699 770 61 441 437 350 690 60 116 240 646 100 306 519 218 186 138 552 283 602 293 258 509 205 543 272 667 85 551 694 653 306 569 34 70 591 693 68 653 114 19 668 296 584 221 273 268 76 424 236 431 369 243 103 617 77 164 370 66 141 634 666 40 457 411 276 322 508 167 118 437 662 195 378 331 149 353 269...
output:
699
result:
ok single line: '699'
Test #27:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
137 531 114 132 88 54 101 51 121 114 66 99 15 59 96 136 37 115 89 38 125 95 100 32 26 89 132 29 115 131 66 95 56 30 68 88 62 1 136 67 85 83 31 41 61 15 126 117 54 102 60 28 84 37 17 92 129 129 61 85 133 73 24 111 10 129 109 55 5 25 53 97 64 113 98 76 61 26 37 71 89 115 99 54 108 96 40 28 47 50 79 37...
output:
137
result:
ok single line: '137'
Test #28:
score: 0
Accepted
time: 0ms
memory: 3884kb
input:
573 855 484 422 387 184 519 507 435 449 60 29 525 396 207 460 429 539 209 518 292 321 196 354 436 185 476 539 37 237 333 30 270 214 201 147 563 171 173 22 240 469 457 27 38 49 211 315 525 410 105 538 339 246 347 311 244 548 271 41 475 345 175 9 503 207 499 511 304 275 82 534 85 268 337 330 500 7 561...
output:
573
result:
ok single line: '573'
Test #29:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
535 759 109 136 43 442 109 124 389 167 306 256 25 430 407 333 14 82 316 164 408 153 504 300 100 129 20 218 257 114 327 129 433 276 528 303 451 339 78 258 135 496 375 484 453 466 73 335 51 189 508 260 363 484 160 111 494 158 374 275 267 2 10 157 129 198 522 403 109 476 422 515 156 483 325 201 403 497...
output:
535
result:
ok single line: '535'
Test #30:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
675 901 135 51 218 653 472 556 556 630 335 225 467 609 374 235 376 164 214 57 44 571 217 369 171 168 194 436 399 398 191 481 364 527 17 644 141 130 160 274 604 73 239 427 151 221 201 159 501 655 366 180 456 664 529 346 15 412 270 399 524 664 502 658 565 268 338 27 105 191 261 228 559 635 447 194 451...
output:
675
result:
ok single line: '675'
Test #31:
score: 0
Accepted
time: 3ms
memory: 3976kb
input:
16265 43720 3000 6495 319 2224 10624 8704 356 6374 7372 2220 3201 7249 15428 7289 2792 1377 13158 1842 2660 1354 14688 14563 2854 8768 5251 9105 1219 8280 11916 9389 15940 15576 10111 16169 13957 2460 9963 7732 8291 446 11367 4531 9507 11521 5980 10365 11043 9398 11925 8322 9817 8631 6083 5230 620 1...
output:
16265
result:
ok single line: '16265'
Test #32:
score: 0
Accepted
time: 0ms
memory: 3796kb
input:
10319 38940 4380 1016 3261 22 2538 8722 395 9209 4075 3225 9619 6236 2323 9625 10063 1199 861 10215 1205 8734 9181 1818 5731 5758 6322 5601 8729 5729 8543 4900 4153 7840 9161 7688 5163 7105 2323 7980 4395 1115 3341 5246 8133 3278 7058 9098 259 8158 3889 3269 6693 1669 6274 6798 7143 5782 491 5364 19...
output:
10319
result:
ok single line: '10319'
Test #33:
score: 0
Accepted
time: 2ms
memory: 3780kb
input:
22435 28221 7635 16887 13019 18640 6674 8639 22303 3293 7287 17170 17490 14880 16041 20192 12621 36 11411 7484 17531 5579 20042 14492 12794 8444 2166 3256 1217 2842 1596 14149 21681 17947 11401 14572 16584 6345 14395 13629 16303 16158 1013 15802 16926 13169 6919 5533 12906 8155 22 20193 7574 22211 8...
output:
22434
result:
ok single line: '22434'
Test #34:
score: 0
Accepted
time: 9ms
memory: 4452kb
input:
41605 77291 28302 11390 14042 34710 5520 3546 23068 29109 11 15211 30951 872 39637 24555 1346 33454 24252 25761 26494 21408 9593 16642 22129 37481 35102 1233 17949 24176 18518 38048 35900 18492 38312 6598 1158 26295 4444 20647 16647 8832 32948 23468 15095 329 6179 40450 3110 39779 35089 24915 6098 3...
output:
41605
result:
ok single line: '41605'
Test #35:
score: 0
Accepted
time: 9ms
memory: 4200kb
input:
36833 47863 35566 36103 15504 723 33354 35297 17279 3692 4402 1327 5594 15063 24945 23051 21454 1975 29490 33196 22517 30135 2834 25262 23244 2442 8944 18642 13507 21653 9595 18471 29556 19013 20685 29936 1003 24759 26738 2896 22781 29713 35812 3902 17304 35398 2050 21609 5422 20180 1352 27030 26043...
output:
36831
result:
ok single line: '36831'
Test #36:
score: 0
Accepted
time: 15ms
memory: 5228kb
input:
69627 79983 11693 59232 20804 57499 14493 8139 43514 14083 65572 69077 7543 67717 34812 62075 14184 39308 58217 19827 64166 64762 1854 52534 6286 41827 53069 9259 30563 21585 20532 17806 68450 13095 63250 22682 43845 52950 40320 41010 67594 34700 16940 48889 63936 40550 11644 27701 36290 50932 3408 ...
output:
69627
result:
ok single line: '69627'
Test #37:
score: 0
Accepted
time: 14ms
memory: 4876kb
input:
54261 85194 39656 916 33638 18726 23883 30126 20812 1754 44221 37179 53504 17418 26927 59 32365 13678 26541 17587 19148 45398 47022 34816 39799 5871 48327 21035 40159 43220 50721 2701 38118 33661 4849 3717 45248 33403 29539 44879 52814 17708 32398 27328 8741 2344 41570 7539 16124 26951 12507 36291 4...
output:
54261
result:
ok single line: '54261'
Test #38:
score: 0
Accepted
time: 6ms
memory: 3996kb
input:
25763 35639 21031 17885 3552 3467 13926 8923 11580 25325 15667 23109 21085 19867 23761 16140 5065 18448 4132 20021 12854 25209 858 11446 3018 5795 15908 6231 1210 14822 6591 20368 1876 8125 13447 2726 5953 2641 22003 6143 17305 15104 18928 10352 20884 3817 10026 1277 4567 3880 21935 168 20688 17228 ...
output:
25762
result:
ok single line: '25762'
Test #39:
score: 0
Accepted
time: 5ms
memory: 4092kb
input:
24239 25034 22156 13687 8612 15530 15891 2683 12907 3886 868 5025 9697 20213 21965 14368 1445 11919 12178 14691 17594 21916 564 20559 20979 15570 8825 19494 25 12303 15687 16910 2481 13968 17253 6038 98 24224 2341 22853 15516 17913 14668 12126 8253 21399 5910 7794 7669 4616 14908 11856 6922 12614 11...
output:
24239
result:
ok single line: '24239'
Test #40:
score: 0
Accepted
time: 15ms
memory: 4748kb
input:
59921 89028 29921 44418 43104 15283 35076 46434 23953 7898 52644 16734 14589 13190 23794 31616 17688 9933 24526 43770 57668 7660 14690 54644 19774 47142 15087 32274 27977 42357 44793 38832 21963 19605 57457 15601 25474 21457 27695 3571 9963 6149 24153 28979 38031 18203 55807 28778 51528 13172 31553 ...
output:
59921
result:
ok single line: '59921'
Test #41:
score: 0
Accepted
time: 0ms
memory: 3560kb
input:
1 0 1
output:
1
result:
ok single line: '1'
Test #42:
score: 0
Accepted
time: 12ms
memory: 5824kb
input:
99997 99998 73211 15658 9854 79737 18021 76757 26896 7046 37231 31954 24374 9482 98575 67491 63691 39172 64886 68007 92716 25008 75828 6895 91792 26130 99408 64333 64386 18364 50545 24096 94911 11249 42757 34478 21146 63830 46936 30677 45244 33412 66793 5151 94464 6833 86876 37812 2742 9179 82802 12...
output:
99997
result:
ok single line: '99997'
Test #43:
score: 0
Accepted
time: 20ms
memory: 5964kb
input:
99999 100000 35555 95526 18477 15417 19665 31285 58874 25232 55610 65415 3416 39758 11471 97668 20362 96700 21705 40889 70692 84619 85340 67783 34440 24877 37237 80836 56911 50136 79096 15047 75768 78454 68094 30722 34897 83598 15118 64100 56776 47587 68331 83923 24827 33193 67499 98430 94312 80294 ...
output:
99999
result:
ok single line: '99999'
Test #44:
score: 0
Accepted
time: 4ms
memory: 4420kb
input:
38211 53386 38211 38211 38211 38211 38211 38211 38211 38211 38211 38211 38211 38211 38211 38211 38211 38211 38211 38211 38211 38211 38211 38211 38211 38211 38211 38211 38211 38211 38211 38211 38211 38211 38211 38211 38211 38211 38211 38211 38211 38211 38211 38211 38211 38211 38211 38211 38211 38211 ...
output:
38211
result:
ok single line: '38211'
Test #45:
score: 0
Accepted
time: 4ms
memory: 4388kb
input:
40391 59821 40391 40391 40391 40391 40391 40391 40391 40391 40391 40391 40391 40391 40391 40391 40391 40391 40391 40391 40391 40391 40391 40391 40391 40391 40391 40391 40391 40391 40391 40391 40391 40391 40391 40391 40391 40391 40391 40391 40391 40391 40391 40391 40391 40391 40391 40391 40391 40391 ...
output:
40391
result:
ok single line: '40391'
Test #46:
score: 0
Accepted
time: 6ms
memory: 3908kb
input:
27185 27184 9512 13823 25975 870 19927 14078 15901 4552 21130 21260 1990 11837 23462 6969 9526 17194 19361 10237 6170 21731 17352 11056 26359 25082 924 11651 4089 24541 9529 16510 1771 14159 2673 1435 26883 9220 9285 6226 16657 8085 10484 5121 24667 20378 9852 19021 1517 23867 419 7189 775 18888 102...
output:
27185
result:
ok single line: '27185'
Test #47:
score: 0
Accepted
time: 7ms
memory: 4564kb
input:
51087 51086 33186 13670 26495 20352 28935 3384 45307 25559 49554 29785 32386 35177 33847 41673 50 14881 48388 18201 4922 16375 26227 28674 5816 36151 33924 49831 7427 19938 40659 21731 14702 32459 41520 18102 30867 1425 19564 22643 29385 34011 27167 12413 3247 26445 14155 20594 15001 46355 39591 129...
output:
51085
result:
ok single line: '51085'
Test #48:
score: 0
Accepted
time: 14ms
memory: 5280kb
input:
67417 67417 43594 24797 50761 67258 14542 67276 63276 16056 9223 1168 43696 65522 63803 6236 59217 35256 15419 37056 54958 35850 58551 47959 63028 25857 49991 49880 1703 48571 61167 33308 15147 65808 53066 39421 39323 57107 40430 36848 797 1577 44317 10972 32951 20690 3416 47922 46476 15745 27023 11...
output:
67417
result:
ok single line: '67417'
Test #49:
score: 0
Accepted
time: 6ms
memory: 4132kb
input:
29763 29762 24053 26156 26234 23413 24284 12860 7199 27279 2727 16193 9885 28977 25377 7622 19231 3302 5106 28168 29717 1422 9822 16497 17251 15129 20177 23469 7700 29487 10101 11976 456 11784 4473 5931 28381 4325 22078 8637 25506 26677 29231 17910 15608 5828 24819 16179 4436 3912 24442 7624 17703 1...
output:
29763
result:
ok single line: '29763'
Test #50:
score: 0
Accepted
time: 12ms
memory: 4744kb
input:
59169 59168 28368 58760 50975 12488 34739 11120 50123 43718 326 9273 21697 53717 36608 43785 18572 48876 47436 39176 27755 13299 26209 37337 3207 45427 35547 56585 55077 42949 21040 729 35621 23843 2232 41813 11287 38347 29450 24485 8512 22958 6624 7140 33464 20598 45804 43092 21783 32855 38054 4310...
output:
59168
result:
ok single line: '59168'