QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#743110#9623. 合成大西瓜Nuyoah#WA 22ms7224kbC++201.1kb2024-11-13 18:15:582024-11-13 18:16:00

Judging History

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

  • [2024-11-13 18:16:00]
  • 评测
  • 测评结果:WA
  • 用时:22ms
  • 内存:7224kb
  • [2024-11-13 18:15:58]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define ull unsigned long long
#define PII pair<int, int>
#define fi first
#define se second
#define inf 0x3f3f3f3f3f3f3f3f
const int N=2e5+10,mod=998244353,P=131;

void solve()
{
    int n , m;
    cin >> n >> m;
    vector<int> a(n + 1);
    vector<vector<int>> p(n + 1);
    for(int i = 1 ; i <= n ; i ++ ) cin >> a[i];
    int x , y;
    while(m -- ) {
        cin >> x >> y;
        p[x].push_back(y);
        p[y].push_back(x);
    }
    sort(a.begin() + 1 , a.end());
    if(n == 1) {
        cout << a[1] << '\n';
        return;
    }
    int ans = 0;
    vector<int> pu;
    for(int i = 1 ; i <= n ; i ++ ) {
        if(p[i].size() == 1) pu.push_back(a[i]);
        else {
            ans = max(ans , a[i]);
        }
    }
    sort(pu.begin() , pu.end());
    if(pu.size() >= 2) ans = max(ans , pu[pu.size() - 2]);
    cout << ans << '\n';
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T=1;
    // cin>>T;
    while (T--)
        solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3532kb

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

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

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: 1ms
memory: 3604kb

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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: 1ms
memory: 3500kb

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

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: 0ms
memory: 3604kb

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: 1ms
memory: 3584kb

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: 1ms
memory: 3792kb

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: 1ms
memory: 3832kb

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: 1ms
memory: 3612kb

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: 1ms
memory: 3528kb

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: 1ms
memory: 3636kb

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: 1ms
memory: 3672kb

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: 11ms
memory: 4996kb

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: 8ms
memory: 4832kb

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: 3ms
memory: 5076kb

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: 22ms
memory: 7224kb

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: -100
Wrong Answer
time: 11ms
memory: 6184kb

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:

36832

result:

wrong answer 1st lines differ - expected: '36831', found: '36832'