QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#605835#2954. RecyclingTokaiZaopenAC ✓7ms6244kbC++201.6kb2024-10-02 19:55:052024-10-02 19:55:07

Judging History

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

  • [2024-10-02 19:55:07]
  • 评测
  • 测评结果:AC
  • 用时:7ms
  • 内存:6244kb
  • [2024-10-02 19:55:05]
  • 提交

answer

#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
// using int = long long;
#define int long long

void solve()
{
    int n;
    cin >> n;
    vector<int> a(n + 1), l(n + 1), r(n + 1);
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    stack<int> st;
    for (int i = 1; i <= n; i++)
    {
        while (!st.empty() && a[i] < a[st.top()])
        {
            r[st.top()] = i - 1;
            st.pop();
        }
        st.push(i);
    }
    while (st.size())
    {
        r[st.top()] = n;
        st.pop();
    }

    for (int i = n; i >= 1; i--)
    {
        while (!st.empty() && a[i] < a[st.top()])
        {
            l[st.top()] = i + 1;
            st.pop();
        }
        st.push(i);
    }
    while (st.size())
    {
        l[st.top()] = 1;
        st.pop();
    }

    int s = n + 1, t = n + 1, maxn = 0;
    for (int i = 1; i <= n; i++)
    {
        if (a[i] * (r[i] - l[i] + 1ll) > maxn)
        {
            maxn = a[i] * (r[i] - l[i] + 1ll);
            s = l[i];
            t = r[i];
        }
        else if (a[i] * (r[i] - l[i] + 1ll) == maxn)
        {
            if (l[i] < s)
            {
                s = l[i];
                t = r[i];
            }
            else if (l[i] == s)
            {
                t = max(t, r[i]);
            }
        }
    }
    cout << s << ' ' << t << ' ' << maxn << endl;
}

signed main()
{
    ios::sync_with_stdio(NULL);
    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: 5ms
memory: 6244kb

input:

100000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

1 100000 100000

result:

ok single line: '1 100000 100000'

Test #2:

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

input:

25
1 3 5 3 1
1 3 5 3 1
1 3 5 3 1
1 3 5 3 1
1 3 5 3 1

output:

1 25 25

result:

ok single line: '1 25 25'

Test #3:

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

input:

21
1 3 5 3 1
3 5 3 1
3 5 3 1
3 5 3 1
3 5 3 1

output:

1 21 21

result:

ok single line: '1 21 21'

Test #4:

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

input:

21
0 3 5 3 0
3 5 3 0
3 5 3 0
3 5 3 0
3 5 3 0

output:

2 4 9

result:

ok single line: '2 4 9'

Test #5:

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

input:

1
0

output:

1 1 0

result:

ok single line: '1 1 0'

Test #6:

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

input:

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

output:

50000 100000 2500050000

result:

ok single line: '50000 100000 2500050000'

Test #7:

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

input:

7
2 5 7 3 5
10 2

output:

2 6 15

result:

ok single line: '2 6 15'

Test #8:

score: 0
Accepted
time: 3ms
memory: 4256kb

input:

39981
598 586 626 966 245 746 877 451 137 248
559 696 151 358 562 53 860 732 352 310
112 209 144 135 601 602 709 680 315 829
708 10 304 490 50 593 181 871 414 201
125 652 982 761 41 532 638 278 367 714
404 409 451 953 462 537 617 285 748 318
49 650 799 288 840 344 716 3 916 210
999 397 558 667 870 5...

output:

6414 6663 13750

result:

ok single line: '6414 6663 13750'

Test #9:

score: 0
Accepted
time: 4ms
memory: 4392kb

input:

53761
965 810 830 532 888 535 687 437 803 166
129 971 452 760 864 126 264 655 496 426
444 212 19 369 557 837 269 171 293 252
400 235 155 635 871 376 26 95 678 247
191 289 780 636 577 246 831 838 553 921
40 711 85 233 694 16 541 634 309 432
930 846 469 65 861 26 733 221 646 601
361 89 798 538 26 715 ...

output:

31134 31359 11074

result:

ok single line: '31134 31359 11074'

Test #10:

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

input:

12752
48 571 355 493 25 296 874 273 239 35
322 5 372 117 764 202 879 246 584 64
49 530 58 293 292 301 655 648 893 311
952 501 3 155 983 484 312 690 607 103
805 132 100 294 577 63 507 836 769 606
615 923 180 360 743 22 615 676 971 706
783 559 896 988 846 950 476 142 980 623
889 656 378 263 886 317 66...

output:

5602 5632 11005

result:

ok single line: '5602 5632 11005'

Test #11:

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

input:

24180
444 65 694 949 702 165 43 631 267 136
881 707 520 295 283 444 260 515 68 700
118 683 675 300 797 242 635 214 955 468
819 867 464 483 913 605 252 150 211 953
712 293 840 512 393 959 972 192 476 348
493 225 812 866 704 897 164 1 46 349
620 973 459 893 471 725 737 523 232 363
152 933 374 832 377 ...

output:

5002 5145 12960

result:

ok single line: '5002 5145 12960'

Test #12:

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

input:

57439
930 637 780 103 492 681 727 360 587 517
556 903 491 624 716 720 642 430 952 330
503 2 383 956 628 874 310 499 143 1000
91 682 178 956 79 980 650 365 666 389
399 26 714 323 847 410 397 231 554 428
350 806 892 981 133 786 765 10 89 208
655 295 755 602 618 481 413 724 100 618
333 579 207 18 852 4...

output:

20166 20375 11970

result:

ok single line: '20166 20375 11970'

Test #13:

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

input:

75487
449 390 510 475 614 178 465 535 281 639
842 402 419 212 208 940 786 326 689 976
358 799 433 663 475 444 423 12 122 284
547 157 46 904 824 599 650 793 66 319
356 334 536 745 507 538 233 563 455 158
774 701 386 684 228 708 260 278 190 408
367 410 702 412 432 825 359 675 768 776
117 767 480 688 6...

output:

30274 30363 10980

result:

ok single line: '30274 30363 10980'

Test #14:

score: 0
Accepted
time: 3ms
memory: 4104kb

input:

43791
900 228 720 727 130 121 266 934 200 185
585 880 941 777 525 397 888 966 143 25
890 901 243 15 298 789 654 940 898 554
865 48 325 660 414 846 420 302 669 587
292 47 566 692 868 337 2 737 945 610
389 921 174 804 23 619 365 16 420 635
635 974 578 262 678 190 432 538 26 809
861 918 535 341 935 715...

output:

23238 23272 10255

result:

ok single line: '23238 23272 10255'

Test #15:

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

input:

25087
154 667 498 398 261 525 406 17 55 482
690 456 461 632 228 504 319 159 878 841
167 759 432 393 13 273 621 569 971 961
384 644 804 789 682 987 185 380 164 803
975 633 892 286 196 631 831 563 382 366
304 418 258 599 864 178 395 663 47 141
869 931 586 974 227 48 637 379 247 649
629 936 175 305 816...

output:

15885 16219 10720

result:

ok single line: '15885 16219 10720'

Test #16:

score: 0
Accepted
time: 5ms
memory: 5040kb

input:

76963
639 814 352 807 211 962 386 7 348 900
385 403 388 789 679 444 298 690 262 225
657 154 714 261 287 381 53 624 577 502
862 340 576 664 327 207 287 921 851 507
575 946 93 86 822 876 81 382 233 85
719 436 631 374 489 473 656 898 887 158
570 418 69 257 487 275 169 749 903 947
932 149 968 432 425 12...

output:

65575 65618 12056

result:

ok single line: '65575 65618 12056'

Test #17:

score: 0
Accepted
time: 3ms
memory: 4436kb

input:

48634
440 576 515 73 862 890 475 150 677 845
706 80 182 32 842 806 505 147 461 597
569 367 676 704 46 334 271 122 352 100
639 481 690 344 533 83 27 892 831 499
902 73 664 5 947 16 163 494 592 212
655 767 492 138 713 581 717 155 756 147
432 600 774 288 947 107 850 918 959 573
933 412 886 958 375 399 ...

output:

25030 25245 11880

result:

ok single line: '25030 25245 11880'

Test #18:

score: 0
Accepted
time: 4ms
memory: 4580kb

input:

54899
251 915 44 199 852 141 859 912 199 484
140 419 914 957 378 567 648 972 289 281
442 505 542 451 827 996 343 746 795 944
203 819 327 630 161 560 78 437 164 661
671 988 840 810 682 392 823 746 679 544
388 613 838 939 914 568 65 517 16 832
19 403 302 530 640 201 878 156 569 800
342 771 20 505 24 7...

output:

53661 53849 11907

result:

ok single line: '53661 53849 11907'

Test #19:

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

input:

56495
91 857 450 11 408 739 294 17 862 101
26 485 374 55 211 192 375 868 125 121
853 854 376 606 249 695 217 459 131 972
256 544 75 842 851 250 328 884 560 659
491 591 964 304 974 792 184 165 699 430
211 396 391 663 254 811 955 357 537 220
617 201 737 676 425 16 555 644 512 476
790 446 656 371 347 8...

output:

43452 43488 12765

result:

ok single line: '43452 43488 12765'

Test #20:

score: 0
Accepted
time: 3ms
memory: 5160kb

input:

85286
623 926 505 712 344 166 303 913 840 958
415 68 1000 305 966 549 222 102 339 349
473 31 711 875 68 986 236 281 292 641
408 830 656 258 942 440 935 301 349 117
754 550 15 112 722 252 152 528 480 873
135 633 56 86 773 581 806 51 950 535
916 190 649 633 58 236 63 139 848 12
196 6 286 881 678 856 4...

output:

35692 36134 14176

result:

ok single line: '35692 36134 14176'

Test #21:

score: 0
Accepted
time: 7ms
memory: 5572kb

input:

99581
48 678 716 568 201 673 268 422 935 628
958 845 736 722 860 577 871 609 79 857
53 782 152 159 979 363 765 367 695 641
703 843 576 264 582 452 463 842 489 97
822 884 664 542 992 148 947 795 542 267
248 562 582 687 802 694 365 367 138 781
455 530 170 455 595 549 384 959 505 116
699 760 357 720 55...

output:

13978 14003 11856

result:

ok single line: '13978 14003 11856'

Test #22:

score: 0
Accepted
time: 6ms
memory: 5640kb

input:

94531
72 587 920 345 196 652 153 792 497 104
126 494 381 93 247 315 680 495 202 49
847 687 770 20 212 29 327 453 762 114
594 574 197 36 54 369 702 326 603 421
879 681 126 479 29 537 313 79 975 578
65 273 969 74 227 278 300 283 890 211
673 475 731 980 399 538 892 854 440 480
697 411 18 118 494 812 87...

output:

70872 70978 12519

result:

ok single line: '70872 70978 12519'

Test #23:

score: 0
Accepted
time: 4ms
memory: 4776kb

input:

59251
506 30 621 756 246 862 622 453 209 519
851 817 903 693 878 450 121 393 628 838
48 305 119 478 764 963 911 552 552 119
900 574 352 964 987 567 713 854 689 130
271 75 705 269 917 918 30 381 753 772
49 624 372 850 408 712 521 495 847 746
512 883 828 836 496 560 800 366 292 985
87 300 409 717 852 ...

output:

42166 42311 11534

result:

ok single line: '42166 42311 11534'

Test #24:

score: 0
Accepted
time: 4ms
memory: 4844kb

input:

64823
927 563 15 707 599 10 774 84 585 263
476 420 245 926 285 121 409 325 886 802
973 860 425 56 451 971 302 769 419 59
934 484 27 294 147 575 732 787 463 79
729 120 418 374 916 546 317 621 2 351
466 212 265 42 838 113 749 7 167 833
91 514 416 194 980 484 492 781 86 579
941 239 539 613 517 383 551 ...

output:

23308 23370 12978

result:

ok single line: '23308 23370 12978'

Test #25:

score: 0
Accepted
time: 5ms
memory: 4608kb

input:

67407
307 346 60 434 452 452 594 519 462 691
534 269 622 636 508 644 153 320 944 842
397 217 280 362 945 605 931 311 767 408
741 481 856 887 918 812 104 291 509 151
828 687 774 169 655 221 218 493 634 706
341 634 420 607 567 864 324 207 979 926
479 627 518 415 684 972 354 116 292 144
32 850 204 746 ...

output:

38633 38722 11790

result:

ok single line: '38633 38722 11790'

Test #26:

score: 0
Accepted
time: 4ms
memory: 4676kb

input:

63706
655 10 617 712 681 702 50 584 863 523
201 483 227 498 790 636 396 672 385 521
116 774 489 631 479 564 980 100 692 504
104 141 633 77 695 218 81 181 314 668
470 197 696 812 593 255 965 94 547 141
749 315 594 2 437 134 502 838 983 245
197 954 48 681 370 338 193 150 611 218
521 317 967 218 891 38...

output:

38177 38245 11937

result:

ok single line: '38177 38245 11937'

Test #27:

score: 0
Accepted
time: 6ms
memory: 5216kb

input:

92204
930 631 189 97 479 243 53 75 884 975
161 389 254 539 509 515 718 264 852 198
797 298 981 749 452 449 464 360 614 958
610 450 750 831 468 449 194 596 94 779
948 195 806 448 480 564 578 536 405 731
769 42 748 962 220 258 365 792 778 412
872 104 482 972 604 515 544 802 25 451
562 363 979 669 845 ...

output:

69570 69658 10680

result:

ok single line: '69570 69658 10680'

Test #28:

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

input:

8
2 5 7 3 5
10 2 4

output:

1 8 16

result:

ok single line: '1 8 16'