QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#497484#5005. GeekflixUmokWA 0ms3788kbC++201.3kb2024-07-29 10:25:532024-07-29 10:25:54

Judging History

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

  • [2024-07-29 10:25:54]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3788kb
  • [2024-07-29 10:25:53]
  • 提交

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'