QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#748590 | #8548. China Convex Polygon Contest | 000226# | WA | 16ms | 3604kb | C++17 | 1.3kb | 2024-11-14 20:48:24 | 2024-11-14 20:48:24 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int n, m, a[200005], b[200005];
void solve() {
cin>>n>>m;
vector<pair<int,int> > g;
for(int i=1;i<=n;i++) {
cin>>a[i];
g.push_back({a[i], 0});
}
int sum=0;
for(int i=1;i<=n;i++) {
cin>>b[i];
}
sort(b+1, b+n+1);
for(int i=1;i<=n;i++) {
sum+=b[i];
g.push_back({sum, 1});
}
sort(g.begin(), g.end());
priority_queue<int, vector<int>, greater<int> > q;
int nxt=1, flag=0, ans=0;
a[n+1]=m;
for(auto tmp:g) {
//cout<<"#"<<tmp.first<<" "<<tmp.second<<endl;
if(tmp.second==1) {
q.push(0);
}
else {
flag=0;
nxt++;
}
if(!q.empty()&&!flag) {
int c=q.top();
//cout<<c<<" "<<a[nxt]<<" "<<tmp.first<<endl;
if(c<a[nxt]-tmp.first) {
ans-=c; ans+=a[nxt]-tmp.first;
q.pop(); q.push(a[nxt]-tmp.first);
flag=1;
}
}
}
cout<<ans<<endl;
}
int main() {
ios :: sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int Case;
cin >> Case;
while (Case --) solve();
return 0;
}
/*
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
*/
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3604kb
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: 16ms
memory: 3576kb
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 548785306 28 875933380 27 796209714 942603170 720683076 536166430 759475944 28 27 28 886112586 27 28 28 727698126 28 27 29 28 28 28 28 27 28 815497632 755946410 28 26 28 789022217 891539003 583799124 817190966 934413263 28 28 865467960 27 27 28 488557236 27 26 604554904 28 27 8041423...
result:
wrong answer 8th numbers differ - expected: '803763192', found: '796209714'