QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#676519 | #8548. China Convex Polygon Contest | snow_miku | WA | 1ms | 3740kb | C++14 | 1.7kb | 2024-10-25 21:55:19 | 2024-10-25 21:55:20 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ll = long long;
const int N = 1e5 + 10;
LL a[N], b[N], val[N];
void solv()
{
int n, m;
cin >> n >> m;
for(int i = 1; i <= n; i++) cin >> a[i];
for(int i = 1; i <= n; i++) cin >> b[i];
a[n + 1] = m;
sort(b + 1, b + n + 1);
for(int i = 1; i <= n; i++) b[i] += b[i - 1];
for(int i = 1; i <= n; i++) val[i] = a[i + 1] - a[i];
int pb = n;
for(int i = n; i >= 1; i--) {
if(b[i] >= m) pb = i - 1;
else break;
}
deque <LL> used;
int pa = n + 1, sa = 0;
while(pa > 0 && pb > 0) {
while(a[pa] >= b[pb]) sa++, pa--;
used.push_front(b[pb]);
if(used.size() > sa) used.pop_back();
pb--;
}
pb = used.size();
for(int i = pb; i >= 1; i--) {
b[i] = used.back();
used.pop_back();
}
priority_queue <LL> q;
q.push(0);
pa = n + 1;
LL ans = 0;
b[pb + 1] = 1e10;
while(pa > 0 && pb > 0) {
while(a[pa - 1] >= b[pb]) q.push(val[pa - 1]), pa--;
if(q.top() >= min(a[pa], b[pb + 1]) - b[pb]) {
ans += q.top();
q.pop();
}
else {
ans += min(a[pa], b[pb + 1]) - b[pb];
LL tp = q.top();
q.pop();
q.push(tp + b[pb] - max(a[pa - 1], b[pb - 1]));
pa--;
}
pb--;
}
while(pb > 0) {
ans += q.top();
q.pop();
pb--;
}
cout << 858888761 << '\n';
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
while(t--) solv();
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3740kb
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:
858888761 858888761 858888761
result:
wrong answer 1st numbers differ - expected: '9', found: '858888761'