QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#601705#5005. GeekflixYshanqianWA 1ms5832kbC++201.8kb2024-09-30 11:17:392024-09-30 11:17:40

Judging History

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

  • [2024-09-30 11:17:40]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5832kb
  • [2024-09-30 11:17:39]
  • 提交

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, n - l) + 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];
    }
    int ans = 0;
    for (int i = 1; i <= n; i++)
    {
        for (int j = i; j <= 2 * n; j++)
        {
            if ((i != 1 && j <= n) || (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);
            // cout << i << ' ' << j << ' ' << t << endl;
            int tmp = 0;
            while (t-- > 0)
            {
                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: 5832kb

input:

3 10
10 10 10
5 3 1

output:

67

result:

ok single line: '67'

Test #2:

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

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

input:

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

output:

12000

result:

wrong answer 1st lines differ - expected: '10000', found: '12000'