QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#497494#5005. GeekflixUmokAC ✓1372ms3836kbC++201.4kb2024-07-29 11:10:272024-07-29 11:10:29

Judging History

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

  • [2024-07-29 11:10:29]
  • 评测
  • 测评结果:AC
  • 用时:1372ms
  • 内存:3836kb
  • [2024-07-29 11:10:27]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define uint unsigned long long
#define int long long
#define endl '\n'
const int N = 1e4 + 5;
typedef pair<int, int> PII;
#define MAX LONG_LONG_MAX

struct node
{
    int a, b;
    bool operator<(const node &x) const
    {
        return a < x.a;
    }
};
int ar[N], br[N], ans = 0;
void solve()
{
    int n, m, ans = 0;
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
        cin >> ar[i], ar[i + n] = ar[i];
    for (int i = 1; i <= n; i++)
        cin >> br[i], br[i + n] = br[i];

    for (int len = 1; len <= n; len++)
    {
        for (int l = 1, r = len; r <= 2 * n; l++, r++)
        {
            int have = m - min(abs(n - l + 1), abs(n - r + 1)) - len + 1;
            
            priority_queue<node> q;
            int sum = 0;
            for (int i = l; i <= r; i ++)
                q.push({ar[i], br[i]});
            for (int i = 1; i <= have && !q.empty(); i++)
            {
                auto x = q.top();
                q.pop();
                if(x.a <= 0)
                    break;
                sum += x.a;
                x.a -= x.b;
                q.push(x);
            }
            ans = max(ans, sum);
        }
    }
    cout << ans << endl;
}
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);

    solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3 10
10 10 10
5 3 1

output:

67

result:

ok single line: '67'

Test #2:

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

input:

5 10
1 2 3 4 5
0 1 2 3 4

output:

16

result:

ok single line: '16'

Test #3:

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

input:

5 5
1 5000 1 1 5000
1 3000 1 1 3000

output:

10000

result:

ok single line: '10000'

Test #4:

score: 0
Accepted
time: 142ms
memory: 3592kb

input:

100 500
1676 3766 611 4073 4277 633 1921 650 4074 4382 1027 1849 861 1199 1411 21 2021 2227 1829 2487 1415 4006 3680 2374 2332 1461 4384 3874 3053 2968 1347 4728 3085 3309 3800 2362 3941 2072 3011 4366 1454 4038 1214 3666 236 2624 38 3608 1202 1866 1094 2616 2223 4774 4989 4554 2586 724 3428 1990 43...

output:

824766

result:

ok single line: '824766'

Test #5:

score: 0
Accepted
time: 133ms
memory: 3608kb

input:

100 500
508 2552 683 490 677 3477 709 4486 2355 1264 1624 2964 3056 3539 1053 883 2164 3116 1411 208 3977 3138 2228 640 3273 3185 3820 2130 4223 3520 4771 1082 2423 453 1571 3099 281 3631 2584 2635 4894 559 599 2949 450 3003 183 2613 1119 1593 2820 1447 1082 47 2087 4355 4584 2258 1484 158 777 2606 ...

output:

1048872

result:

ok single line: '1048872'

Test #6:

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

input:

200 1000
1330 4669 1496 1583 4725 3593 1619 1993 3869 1502 3311 449 3084 4185 2087 3790 2814 187 776 93 348 1903 3901 301 2614 155 4366 1627 4816 1554 3549 1145 1986 808 3491 1710 4401 109 4467 3269 1612 2777 3718 458 2724 1567 10 538 1755 786 1394 2103 3452 1057 3167 1828 1212 2532 3455 1028 4087 2...

output:

1832005

result:

ok single line: '1832005'

Test #7:

score: 0
Accepted
time: 1363ms
memory: 3560kb

input:

200 1000
3641 3410 1374 3191 4728 4765 1705 3427 626 2596 791 3750 1808 2798 3407 1441 895 3986 475 4617 2814 3598 3427 1294 3233 3269 4390 2366 2851 28 3512 2254 4201 4886 445 4692 4650 2913 3118 1039 508 3910 4789 3079 1707 3958 4521 3366 2943 758 3745 757 4356 2171 2051 3351 1202 2203 716 4053 29...

output:

2090421

result:

ok single line: '2090421'

Test #8:

score: 0
Accepted
time: 1180ms
memory: 3600kb

input:

200 1000
1820 1421 3901 3088 2176 48 788 723 2663 1075 976 1666 3988 4266 373 3024 2794 1948 3913 1597 3728 4967 2276 432 2473 142 1571 4619 359 4038 4585 2180 1221 3485 267 3398 3533 1055 4121 1959 2131 859 3625 1881 887 4762 667 4444 2472 4580 1041 1199 308 4080 1631 2781 4985 3965 2399 343 3766 2...

output:

1807924

result:

ok single line: '1807924'

Test #9:

score: 0
Accepted
time: 1372ms
memory: 3624kb

input:

200 1000
2178 3230 2999 1413 2287 86 2788 1743 671 4695 4931 4790 2287 1297 4165 1711 2293 3607 1268 2572 2354 2450 1041 983 4010 2602 4787 2874 2341 3124 2476 281 1354 474 1694 4404 561 245 1146 1995 4940 1839 1785 2226 3136 949 4700 1192 318 968 3764 2673 4181 567 4419 3190 3932 4968 1827 2036 309...

output:

1841598

result:

ok single line: '1841598'

Test #10:

score: 0
Accepted
time: 1273ms
memory: 3556kb

input:

200 1000
1783 4088 4817 688 1396 2313 521 4878 3809 1868 954 1027 4430 3196 3176 4182 4634 2328 310 4426 4915 3399 997 3133 738 3967 3286 3428 2038 43 3981 3821 4894 4561 271 2052 2636 1555 1929 1444 3423 3647 3234 3615 2605 2172 3560 2238 262 3870 1663 177 2269 2660 3310 3770 2389 1595 2198 4427 24...

output:

1800224

result:

ok single line: '1800224'

Test #11:

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

input:

200 1000
2801 4093 1121 3782 4208 1617 4989 2980 880 970 1191 1110 720 278 3570 818 4777 3270 307 3890 3513 1678 2792 4644 3670 1737 3968 1128 3121 4723 2897 921 3815 4781 466 3022 2160 454 1765 3040 2187 2956 4150 2907 3234 3482 3725 3774 2514 4795 3426 1790 1472 1218 2196 904 3718 1163 2795 1838 8...

output:

2092022

result:

ok single line: '2092022'

Test #12:

score: 0
Accepted
time: 1273ms
memory: 3560kb

input:

200 1000
4298 3221 1085 1146 4954 2066 4312 4382 2676 1518 3857 527 2020 2325 547 2729 605 3445 1331 764 2389 1532 2621 4156 2709 2788 1428 4822 1142 3266 3326 440 1486 174 2349 2202 2240 1660 1584 678 3179 1203 1205 198 3529 2515 3690 4897 959 20 1423 4111 2316 4044 4030 24 2594 457 608 3737 4486 3...

output:

2001506

result:

ok single line: '2001506'

Test #13:

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

input:

200 1000
4221 3578 3080 1365 3305 2037 1413 587 634 4099 4995 3931 2289 2130 4480 2972 340 986 1141 3857 1138 4659 1326 1873 4626 1730 1893 2944 4994 3127 1384 4977 1705 4464 1341 9 2263 3517 1360 2897 3379 2117 2590 667 4248 2832 4402 350 4581 542 4970 718 963 2058 3354 588 3788 247 3532 4544 4137 ...

output:

1877106

result:

ok single line: '1877106'

Test #14:

score: 0
Accepted
time: 1367ms
memory: 3520kb

input:

200 1000
0 4913 2123 1050 1956 1727 5 2190 2570 3579 246 1472 1506 3059 412 3305 1250 1930 283 1496 2478 2044 1634 4736 1775 2784 4664 1887 3502 503 4962 4266 415 2847 315 3135 336 321 1087 2906 4663 1334 140 1168 4393 1316 235 1405 3246 518 3664 1486 2562 1060 1985 4338 4607 2411 1224 3109 2915 194...

output:

1971804

result:

ok single line: '1971804'

Test #15:

score: 0
Accepted
time: 144ms
memory: 3540kb

input:

100 500
2542 3986 1113 666 1309 2286 3287 2044 2003 4779 1936 324 3606 4094 1843 617 1401 2093 2024 2945 4952 3271 1541 3623 1190 4012 4621 1029 2558 1576 3456 1451 1913 920 2117 3222 4557 1755 1617 1560 2886 3553 3235 2843 3998 77 3460 399 2170 483 4695 3473 105 2588 2095 1294 1599 3067 3674 509 46...

output:

827677

result:

ok single line: '827677'

Test #16:

score: 0
Accepted
time: 1262ms
memory: 3536kb

input:

200 1000
2894 2966 1019 661 3949 1212 1656 2917 1951 2808 4925 3845 3733 2360 3266 1468 546 1146 4115 3677 2744 4601 2426 4045 390 1968 3692 4562 1917 4716 3380 4811 2681 161 472 2392 2136 2891 1071 4851 698 1759 4458 193 4882 2723 1661 427 4632 1538 4867 2375 1138 2292 1419 2291 23 874 2615 1940 58...

output:

1878885

result:

ok single line: '1878885'

Test #17:

score: 0
Accepted
time: 146ms
memory: 3552kb

input:

100 500
4296 2009 3679 3726 419 2378 2676 3272 4748 2308 4624 1374 2529 4174 2345 1582 3321 4839 4072 1669 269 3345 1956 182 3563 2229 4513 4524 2289 1767 2558 1584 128 2589 1661 546 4966 4336 170 4713 1644 4793 1086 524 318 4782 3457 3639 4621 2528 1659 4889 2224 4966 1422 2138 2194 934 1661 4483 2...

output:

771658

result:

ok single line: '771658'

Test #18:

score: 0
Accepted
time: 139ms
memory: 3560kb

input:

100 500
3445 3014 418 373 4500 824 4728 3464 3384 3089 1470 3826 2920 1112 3789 1963 2390 1905 4902 574 4768 3715 4182 1815 2639 2446 3349 4353 1252 1541 269 1049 906 2038 1421 405 2862 1149 220 1245 589 1689 70 4860 4153 210 1822 1542 3467 1723 2115 3234 438 2648 48 3076 93 4748 2428 2697 2640 4048...

output:

657396

result:

ok single line: '657396'

Test #19:

score: 0
Accepted
time: 120ms
memory: 3484kb

input:

100 500
1912 4259 3498 3960 3497 3382 3263 1442 1441 2482 3351 725 3848 3410 745 2410 766 608 4380 3860 546 2337 242 4252 3370 974 361 4192 3056 1805 2358 4967 2416 855 3926 2264 588 3541 3705 2029 2374 2055 2753 1221 1816 4849 3630 2582 456 4362 1441 2353 1698 3034 2956 67 359 3316 4259 3414 121 16...

output:

1281898

result:

ok single line: '1281898'

Test #20:

score: 0
Accepted
time: 144ms
memory: 3624kb

input:

100 500
518 1371 3373 4353 1925 3726 3714 979 283 528 1666 311 1940 2055 49 737 2371 1789 4485 258 3912 692 243 1378 1402 2569 1779 3998 880 2198 4658 2749 3569 3030 2101 1845 1756 2167 2823 3390 2694 840 3701 4633 2894 3749 1721 1617 1889 1206 1874 801 3249 3468 3530 4650 2388 1660 5000 4620 3857 4...

output:

975745

result:

ok single line: '975745'

Test #21:

score: 0
Accepted
time: 156ms
memory: 3596kb

input:

100 500
637 3521 708 850 1370 1521 4332 4220 1030 4252 935 5 2637 373 3592 920 2521 2122 1650 973 1286 4753 3731 2979 4229 52 1024 2391 297 2336 4530 2285 856 1589 4486 3577 3109 3817 4148 491 4421 83 495 2057 1807 438 4328 4327 3912 978 1652 197 2082 382 3175 1310 433 551 3701 2081 2886 4582 4365 9...

output:

1022912

result:

ok single line: '1022912'

Test #22:

score: 0
Accepted
time: 125ms
memory: 3600kb

input:

100 500
1167 2741 3882 3242 1013 1759 4022 4941 536 3744 875 3144 4718 4505 3697 4763 4893 4449 699 1260 3868 1353 2810 1034 728 4580 1170 1505 2142 177 1434 3308 2917 315 2901 281 3425 1922 222 3961 666 2448 3456 1735 1952 2152 1498 1844 1601 3548 4455 1820 4901 2264 4205 1980 3196 1726 3484 1689 1...

output:

983493

result:

ok single line: '983493'

Test #23:

score: 0
Accepted
time: 150ms
memory: 3488kb

input:

100 500
3175 3968 1859 1772 718 1926 1621 661 3091 4265 860 1404 3506 824 2428 3607 1733 2849 1512 4439 2850 3651 4978 2075 4501 2346 4082 306 281 929 1404 4807 4897 4615 1579 1966 2892 4551 3978 982 167 4837 3737 3673 661 1165 2279 3745 365 142 4535 4567 3792 4512 2993 4644 3209 2074 4949 3489 4354...

output:

1025530

result:

ok single line: '1025530'