CT21408

The First Repeat of Whitewick

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

Zane the ledger master watches over the cotton rows of Whitewick's stores of stamps. A careful computation stands between order and chaos. Task: Read n integers and print the first value that appears twice (the value whose second occurrence has the smallest index). If all are distinct print -1. Input format: First line: n. Second line: n space-separated integers. Output format: Print the first repeated value, or -1. Constraints: 1 <= n <= 386; 0 <= a[i] <= 1000; answers fit a signed 64-bit integer.

Example 1:

Input: 65 289 133 879 728 228 379 528 478 639 899 490 832 921 273 714 774 585 737 797 402 416 134 342 860 656 149 897 654 573 484 853 73 400 779 834 488 991 773 213 717 99 744 292 276 777 303 402 334 682 486 384 874 503 659 402 128 710 89 502 112 533 176 315 640 572
Output: 402

Example 2:

Input: 264 327 680 565 642 294 772 720 681 537 692 510 355 166 827 222 567 281 73 441 68 398 833 330 30 661 842 372 691 428 559 876 154 278 858 22 311 532 14 924 918 721 231 472 695 481 905 870 579 817 263 8 257 756 100 33 559 370 411 678 717 988 247 161 867 853 931 647 387 975 493 835 594 685 823 212 186 88 538 424 946 936 898 373 155 2 656 407 27 337 497 424 45 454 488 57 295 101 847 480 224 404 708 61 430 449 410 209 546 184 626 78 125 378 722 487 172 63 320 744 457 948 35 421 805 191 314 301 318 12 827 544 821 622 296 161 778 139 969 450 606 709 80 149 839 377 768 370 993 50 296 541 946 756 410 218 175 986 291 773 670 360 936 473 209 41 274 517 507 456 431 722 76 889 519 481 423 773 9 299 350 930 183 862 865 31 233 560 616 123 70 743 569 5 386 982 634 311 164 162 814 17 349 870 810 460 181 698 12 904 759 729 836 30 312 921 526 865 204 461 241 364 500 707 242 54 319 311 853 805 432 587 587 305 264 770 564 934 321 157 475 666 458 502 591 647 109 734 661 260 194 376 270 73 487 546 209 20 485 975 313 637 817 733 300
Output: 559

Example 3:

Input: 385 705 318 710 253 112 161 78 768 841 128 51 630 365 504 299 210 876 230 649 550 957 413 299 404 912 311 244 927 220 392 81 656 27 990 89 237 705 48 617 388 611 332 9 913 299 903 213 327 434 44 219 923 273 233 330 899 639 557 459 496 656 330 653 619 54 833 553 216 669 163 567 496 264 664 569 110 332 209 595 33 551 790 155 650 175 956 154 673 815 638 305 813 246 65 469 19 291 736 295 413 713 924 610 816 991 431 612 284 501 983 276 647 339 141 352 628 373 67 424 460 254 876 452 323 914 71 960 441 483 847 767 777 166 663 960 844 184 905 526 35 343 631 40 843 863 266 351 54 463 941 781 370 150 412 161 927 916 77 524 677 152 815 311 316 156 428 654 897 860 291 503 512 893 115 493 327 527 523 135 565 499 239 256 15 825 955 632 803 922 152 590 455 801 618 846 275 360 790 692 136 710 605 570 503 423 72 105 715 93 666 645 275 796 989 739 403 39 343 278 565 288 583 596 476 629 776 416 79 41 646 361 2 254 641 72 317 582 102 59 609 340 660 231 357 170 384 72 435 77 398 95 318 61 231 596 799 864 99 888 797 504 112 387 695 728 405 950 889 694 737 522 603 986 594 610 8 836 372 37 314 684 931 900 726 882 714 21 463 780 672 424 314 316 833 526 191 612 121 200 20 943 51 329 272 195 402 204 44 728 414 301 142 976 307 577 14 436 568 749 465 419 455 114 59 295 354 893 319 923 284 145 855 858 473 180 114 581 809 886 242 861 821 612 266 55 168 587 1 851 762 833 756 825 23 668 735 586 819 342 827 546 649 526 98 42 626 54 877 946 323 70 253 398 220 501 979 13 206 251 739 515 665 8 970 564
Output: 299

Constraints:

1 <= n <= 386; 0 <= a[i] <= 1000; answers fit a signed 64-bit integer.

Loading...
Test Cases:No test cases
No test cases available.