QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#882230#8548. China Convex Polygon ContestxujindongWA 38ms3584kbC++14759b2025-02-04 22:29:462025-02-04 22:29:46

Judging History

This is the latest submission verdict.

  • [2025-02-04 22:29:46]
  • Judged
  • Verdict: WA
  • Time: 38ms
  • Memory: 3584kb
  • [2025-02-04 22:29:46]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
int t,n,m,k,a[100005],b[100005],ans;
int main(){
  cin>>t;
  while(t--){
    cin>>n>>m,k=n;
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=1;i<=n;i++)cin>>b[i];
    sort(b+1,b+n+1);
    for(int i=1;i<=n;i++){
      b[i]+=b[i-1];
      if(b[i]>=m){
        k=i-1;
        break;
      }
    }
    priority_queue<int>q;
    for(int i=k,j=n,pre=m;i>=1;i--){
      q.push(0);
      while(j>=1&&a[j]>b[i])q.push(pre-a[j]),pre=a[j--];
      if(a[j]<=b[i-1])ans+=q.top(),q.pop();
      else{
        int now=q.top();
        q.pop();
        if(pre-b[i]<=now)ans+=now;
        else ans+=pre-b[i],q.push(now+b[i]-a[j]),pre=a[j];
      }
    }
    cout<<ans<<'\n',ans=0;
  }
  return 0;
}

詳細信息

Test #1:

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

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
Wrong Answer
time: 38ms
memory: 3584kb

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:

754749634
25
25
548785306
28
875933380
24
796209714
624849894
720683076
496614303
759475944
28
27
28
602343928
25
22
22
711205025
25
25
29
28
28
23
25
27
28
815497632
755946410
28
26
28
673105692
891539003
381951593
678803216
729041494
24
24
792052331
27
23
29
483836554
25
26
587805500
28
22
8041423...

result:

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