QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#882228#8548. China Convex Polygon ContestxujindongRE 0ms3584kbC++14759b2025-02-04 22:28:542025-02-04 22:28:55

Judging History

This is the latest submission verdict.

  • [2025-02-04 22:28:55]
  • Judged
  • Verdict: RE
  • Time: 0ms
  • Memory: 3584kb
  • [2025-02-04 22:28:54]
  • 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=m;
    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: 0ms
memory: 3584kb

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: