QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#732931#8548. China Convex Polygon Contestarnold518#RE 0ms3804kbC++171.4kb2024-11-10 16:32:382024-11-10 16:32:38

Judging History

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

  • [2024-11-10 16:32:38]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:3804kb
  • [2024-11-10 16:32:38]
  • 提交

answer

#include <bits/stdc++.h>
#define X first
#define Y second
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long long lint;

const int N = 100005;

int n, m, a[N], b[N];

void solve ()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++) {
        scanf("%d",&a[i]);
    }
    a[n+1] = m;
    for(int i=1;i<=n;i++) {
        scanf("%d",&b[i]);
    }
    sort(b+1, b+1+n);
    vector<pii> gugan;
    vector<int> jum;
    for(int i=1;i<=n;i++) {
        gugan.push_back({a[i], a[i+1]});
    }
    for(int i=1;i<=n;i++) {
        b[i] += b[i-1];
        if (b[i] < m) jum.push_back(b[i]);
        else break;
    }
    priority_queue<int> prof;
    long long ans = 0;
    int gi = (int)gugan.size()-1;
    int zp = 0, zb = 0;
    for(int i=(int)jum.size()-1;i>=0;i--) {
        int cj = jum[i];
        while(gi >= 0 && cj <= gugan[gi].X) {
            prof.push(gugan[gi].Y - gugan[gi].X - zp + zb);
            zp = 0;
            zb = 0;
            gi--;
        }
        int tp = prof.top();
        if (gi >= 0 && tp < gugan[gi].Y - cj - zp + zb) {
            ans += gugan[gi].Y - cj - zp + zb;
            zp = gugan[gi].Y - cj;
            zb = tp;
        }
        else {
            ans += tp;
        }
        prof.pop();
    }
    printf("%lld\n", ans);
}

int main()
{
    //ios_base::sync_with_stdio(false); cin.tie(NULL);

    int TC;
    cin >> TC;
    while(TC--)
    {
        solve();
    }
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3804kb

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:

9
9
7

result:

ok 3 number(s): "9 9 7"

Test #2:

score: -100
Runtime Error

input:

10000
9 879847766
125098132 150509852 181700303 196375322 519766842 560891576 609151480 721527163 805167083
99031467 66330518 6283986 21388462 41109537 83628243 116141243 144052767 192448599
8 30
5 12 16 19 20 23 25 27
3 1 1 4 2 8 2 3
8 30
4 10 13 16 17 20 23 27
6 3 1 2 3 4 7 2
7 586479012
37693706 ...

output:


result: