QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#601734#5005. GeekflixYshanqianWA 83ms5872kbC++201.9kb2024-09-30 11:41:422024-09-30 11:41:42

Judging History

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

  • [2024-09-30 11:41:42]
  • 评测
  • 测评结果:WA
  • 用时:83ms
  • 内存:5872kb
  • [2024-09-30 11:41:42]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define xx first
#define yy second
#define endl "\n"
#define pb push_back
#define int long long
#define ll long long
#define lowbit(x) x & (-x)
typedef pair<int, int> pii;
#define LF(x) fixed << setprecision(x)
#define Yshanqian ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
const int N = 1e6 + 10, M = 1010, inf = 0x3f3f3f3f, mod = 1e9 + 7, P = 13331;
int n, m;
int a[N], b[N];
int get(int x, int y)
{
    return max(0ll, a[x] - (y - 1) * b[x]);
}
int dis(int l, int r)
{
    if (l == 1)
        return r - l;
    return min(r - n + 1, n - l + 1) + r - l;
}
void solve()
{
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
        cin >> a[i], a[i + n] = a[i];
    for (int i = 1; i <= n; i++)
        cin >> b[i], b[i + n] = b[i];
    auto in = [&](int l, int r)
    {
        if (l <= 1 && 1 <= r)
            return true;
        if (l <= n && n <= r)
            return true;
        return false;
    };

    int ans = 0;
    for (int i = 1; i <= 2 * n; i++)
    {
        for (int j = i; j <= 2 * n; j++)
        {
            if (!in(i, j) || (j - i + 1) > n)
                continue;
            priority_queue<array<int, 3>> q;
            for (int k = i; k <= j; k++)
                q.push({get(k, 1), k, 1});
            int t = m - dis(i, j);
            int tmp = 0;
            for (int k = 1; k <= t; k++)
            {
                auto [w, id, cnt] = q.top();
                q.pop();
                tmp += w;
                q.push({get(id, cnt + 1), id, cnt + 1});
            }
            ans = max(ans, tmp);
        }
    }
    cout << ans << endl;
}
signed main()
{
    Yshanqian;
    int T;
    T = 1;
    // cin >> T;
    for (int cases = 1; cases <= T; ++cases)
    {
        // cout<<"Case #"<<cases<<": ";
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 5524kb

input:

3 10
10 10 10
5 3 1

output:

67

result:

ok single line: '67'

Test #2:

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

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: 1ms
memory: 5612kb

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: 83ms
memory: 5872kb

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: 79ms
memory: 5612kb

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:

1048846

result:

wrong answer 1st lines differ - expected: '1048872', found: '1048846'