QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#497491 | #5005. Geekflix | Umok | WA | 143ms | 3804kb | C++20 | 1.4kb | 2024-07-29 11:08:29 | 2024-07-29 11:08:30 |
Judging History
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 = -1;
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: 3804kb
input:
3 10 10 10 10 5 3 1
output:
67
result:
ok single line: '67'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3620kb
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: 3528kb
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: 143ms
memory: 3600kb
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: -100
Wrong Answer
time: 133ms
memory: 3584kb
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:
1049832
result:
wrong answer 1st lines differ - expected: '1048872', found: '1049832'