QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#545794 | #8548. China Convex Polygon Contest | WA_Synadrome# | WA | 18ms | 5876kb | C++20 | 1.8kb | 2024-09-03 17:19:12 | 2024-09-03 17:19:13 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e5+10;
int a[N],b[N],n,m,del[N];
struct tmp{
int t,op,id;
bool operator < (const tmp x) const {
if (t==x.t) return op<x.op;
return t<x.t;
}
}s[N<<2];
void solve() {
cin>>n>>m;
for (int i=1;i<=n;i++) cin>>a[i]; a[n+1]=m;
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]+b[i];
int p=0;
for (int i=1;i<=n;i++) s[++p]={a[i],0,i},del[i]=0;
for (int i=1;i<=n;i++) if (b[i]<=m) s[++p]={b[i],1,i}; else b[i]=m; b[n+1]=m;
sort(s+1,s+p+1); s[p+1]={m,0,0};
int bef=0,nxt=1,cnt=0,fl=1,ans=0;
priority_queue<int,vector<int>,greater<int>> q;
for (int i=1;i<=p;i++) {
int t=s[i].t,op=s[i].op,id=s[i].id;
// cout<<t<<' '<<op<<' '<<id<<'\n'<<flush;
if (op==0) {
bef=id,nxt=id+1; fl=1;
if (cnt>=1) {
--cnt; fl=0;
q.push(a[nxt]-a[bef]);
ans+=a[nxt]-a[bef];
} else if (!q.empty()) {
int T=s[i+1].t,OP=s[i+1].op,ID=s[i+1].id,dur;
dur=T-t;
if (q.top()<=dur) {
ans=ans-q.top()+a[nxt]-a[bef];
q.pop(); q.push(a[nxt]-a[bef]);
fl=0;
} else {
if (OP==1) {
int las=q.top();
if (a[nxt]-a[bef]<=las) continue;
q.pop(); int xxx=a[nxt]-T-(a[nxt]-a[bef]-las);
q.push(xxx); q.push(a[nxt]-a[bef]); del[ID]=1; fl=0;
// las ->
// q.push(min(a[nxt]-a[bef],las-dur));
// q.push(min(xxx-dur,)); q.push(a[nxt]-T); del[ID]=1; fl=0;
}
}
}
}
else {
if (del[id]) continue;
if (fl) {
q.push(a[nxt]-t); fl=0;
ans+=a[nxt]-t;
} else ++cnt;
} // cout<<1<<flush<<'\n';
// cout<<ans<<'\n';
}
cout<<ans<<'\n';
}
signed main() {
ios::sync_with_stdio(0);
int T; cin>>T; while (T--) solve();
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 5668kb
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: 18ms
memory: 5876kb
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:
858888761 28 27 460660076 24 875933380 27 613338563 942603170 720683076 536166430 759475944 24 24 28 886112586 27 28 28 727698126 28 25 29 28 28 26 28 27 28 788280027 640299850 25 19 22 693551899 891539003 583799124 817190966 934413263 28 28 865467960 27 27 27 396856375 27 22 546721512 23 27 7410092...
result:
wrong answer 4th numbers differ - expected: '548785306', found: '460660076'