QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#497484 | #5005. Geekflix | Umok | WA | 0ms | 3788kb | C++20 | 1.3kb | 2024-07-29 10:25:53 | 2024-07-29 10:25:54 |
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;
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 l = 1; l <= n; l++)
{
for (int r = n; r <= 2 * n; r++)
{
if (r - l + 1 > n)
break;
priority_queue<node> q;
for (int i = l; i <= r; i++)
q.push({ar[i], br[i]});
int have = m - n + 1 - min(n - l + 1, r - n);
int sum = 0;
for (int i = 1; i <= have && !q.empty(); i++)
{
auto x = q.top();
q.pop();
sum += x.a;
x.a -= x.b;
if (x.a > 0)
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: 3788kb
input:
3 10 10 10 10 5 3 1
output:
67
result:
ok single line: '67'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3660kb
input:
5 10 1 2 3 4 5 0 1 2 3 4
output:
16
result:
ok single line: '16'
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3616kb
input:
5 5 1 5000 1 1 5000 1 3000 1 1 3000
output:
5000
result:
wrong answer 1st lines differ - expected: '10000', found: '5000'