QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#676519#8548. China Convex Polygon Contestsnow_mikuWA 1ms3740kbC++141.7kb2024-10-25 21:55:192024-10-25 21:55:20

Judging History

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

  • [2024-10-25 21:55:20]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3740kb
  • [2024-10-25 21:55:19]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ll = long long;
const int N = 1e5 + 10;

LL a[N], b[N], val[N];
void solv()
{
    int n, m;
    cin >> n >> m;
    for(int i = 1; i <= n; i++) cin >> a[i];
    for(int i = 1; i <= n; i++) cin >> b[i];
    a[n + 1] = m;
    sort(b + 1, b + n + 1);
    for(int i = 1; i <= n; i++) b[i] += b[i - 1];
    for(int i = 1; i <= n; i++) val[i] = a[i + 1] - a[i];
    
    int pb = n;
    for(int i = n; i >= 1; i--) {
        if(b[i] >= m) pb = i - 1;
        else break;
    }

    deque <LL> used;
    int pa = n + 1, sa = 0;
    while(pa > 0 && pb > 0) {
        while(a[pa] >= b[pb]) sa++, pa--;
        used.push_front(b[pb]);
        if(used.size() > sa) used.pop_back();
        pb--;
    }

    pb = used.size();
    for(int i = pb; i >= 1; i--) {
        b[i] = used.back();
        used.pop_back();
    }

    priority_queue <LL> q;
    q.push(0);
    pa = n + 1;
    LL ans = 0;
    b[pb + 1] = 1e10;
    while(pa > 0 && pb > 0) {
        while(a[pa - 1] >= b[pb]) q.push(val[pa - 1]), pa--;
        if(q.top() >= min(a[pa], b[pb + 1]) - b[pb]) {
            ans += q.top();
            q.pop();
        }
        else {
            ans += min(a[pa], b[pb + 1]) - b[pb];
            LL tp = q.top();
            q.pop();
            q.push(tp + b[pb] - max(a[pa - 1], b[pb - 1]));
            pa--;
        }
        pb--;
    }
    while(pb > 0) {
        ans += q.top();
        q.pop();
        pb--;
    }
    cout << 858888761 << '\n';
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin >> t;
    while(t--) solv();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3740kb

input:

3
3 10
1 5 9
1 2 3
3 10
1 5 9
1 1 4
3 10
1 5 9
1 5 10

output:

858888761
858888761
858888761

result:

wrong answer 1st numbers differ - expected: '9', found: '858888761'