QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#642072 | #8548. China Convex Polygon Contest | youthpaul | WA | 9ms | 3780kb | C++20 | 1.7kb | 2024-10-15 09:39:31 | 2024-10-15 09:39:32 |
Judging History
answer
#include<bits/stdc++.h>
#define fore(i,l,r) for(int i=(int)(l);i<(int)(r);++i)
#define fi first
#define se second
#define endl '\n'
#define ull unsigned long long
#define ALL(v) v.begin(), v.end()
#define Debug(x, ed) std::cerr << #x << " = " << x << ed;
const int INF=0x3f3f3f3f;
const long long INFLL=1e18;
typedef long long ll;
int main(){
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
std::cout.tie(nullptr);
int t;
std::cin >> t;
while(t--){
int n, m;
std::cin >> n >> m;
std::vector<int> a(n + 2);
fore(i, 1, n + 1) std::cin >> a[i];
a[n + 1] = m;
std::vector<int> b(n);
fore(i, 0, n) std::cin >> b[i];
std::sort(ALL(b));
std::vector<int> t;
int lst = 0;
for(auto x : b){
if(lst + x >= m) break;
lst += x;
t.push_back(lst);
}
int idx = t.size() - 1;
int ans = 0;
std::priority_queue<int> q;
for(int i = n + 1; i > 0; --i){
int l = a[i - 1], r = a[i];
int cnt = 0, t1 = 0;
while(idx >= 0 && t[idx] >= r) --idx;
while(idx >= 0 && t[idx] >= l){
++cnt;
t1 = t[idx];
--idx;
}
if(!cnt) q.push(r - l);
else{
fore(k, 0, cnt - 1){
if(q.empty()) break;
ans += q.top();
q.pop();
}
ans += r - t1;
if(q.empty() || q.top() < r - t1){
int x = (q.empty() ? 0 : q.top());
q.push(t1 - l + x);
}
else{
ans += q.top();
q.pop();
q.push(r - l);
}
}
}
std::cout << ans << endl;
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3780kb
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: 9ms
memory: 3600kb
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:
955936642 34 35 668459332 33 950217218 34 910758557 1112173340 822756553 591780351 853483681 35 31 37 949896599 33 34 30 953899166 32 31 33 32 30 31 34 33 37 1015832869 968643088 33 30 37 890636543 1141835991 599500767 884156431 1153639910 35 35 902792613 34 29 32 585575186 32 32 659064431 33 29 985...
result:
wrong answer 1st numbers differ - expected: '858888761', found: '955936642'