QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#795254 | #9599. Dragon Bloodline | Loxilante | WA | 403ms | 4284kb | C++20 | 1.6kb | 2024-11-30 18:58:26 | 2024-11-30 18:58:29 |
Judging History
answer
#include <bits/stdc++.h>
#define rep(i, l, r) for(int i = l; i < r; i++)
#define hrp(i, l, r) for(int i = l; i <= r; i++)
#define rev(i, r, l) for(int i = r; i >= l; i--)
#define int ll
using namespace std;
typedef long long ll;
template<typename tn = int> tn next(void) { tn k; cin>>k; return k; }
#ifndef LOCAL
#define D(...) 0
#define I(...) 0
#endif
const int U = 1.2e5;
int a[U], b[U], n, k;
bool check(int mul)
{
priority_queue<int> pq;
rep(i, 0, n) pq.push(a[i]*mul);
vector<int> bt;
rep(i, 0, k) bt.push_back(b[i]);
rev(i, k-1, 0) while(bt[i] && pq.top() > 0)
{
int t = pq.top(), g = min(bt[i], max(1LL, t/(1<<i))); pq.pop();
t -= g*(1<<i);
bt[i] -= g;
pq.push(t);
}
return pq.top() <= 0;
}
signed main(void)
{
#ifdef LOCAL
// freopen("C:\\Users\\Loxil\\Desktop\\IN.txt", "r", stdin);
// freopen("C:\\Users\\Loxil\\Desktop\\OUT.txt", "w", stdout);
#endif
ios::sync_with_stdio(false);
cin.tie(0);
int T = next();
while(T--)
{
cin>>n>>k;
rep(i, 0, n) cin>>a[i];
rep(i, 0, k) cin>>b[i];
int l = 0, r = 1.5e18;
while(l < r)
{
int mid = l+r+1>>1;
if (check(mid)) l = mid;
else r = mid-1;
}
cout<<l<<endl;
}
return 0;
}
/*
1
1 20
1
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000
*/
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3628kb
input:
6 4 3 1 2 3 4 4 4 4 3 2 1 1 1 1 7 3 4 6 6 2 1 1 5 5 3 5 3 1 1 1 1 1 1 1 4 5 1 9 9 8 2 2 2 3 1 5 4 1 3 1 7 1 4 1 5 2
output:
2 4 4 5 2 3
result:
ok 6 lines
Test #2:
score: 0
Accepted
time: 0ms
memory: 3564kb
input:
1 1 20 1 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000
output:
1048575000000000
result:
ok single line: '1048575000000000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
2 3 2 1 1 1 1 7 4 2 1 1 1 1 1 2
output:
4 0
result:
ok 2 lines
Test #4:
score: 0
Accepted
time: 403ms
memory: 4284kb
input:
1 50000 20 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...
output:
1048575
result:
ok single line: '1048575'
Test #5:
score: -100
Wrong Answer
time: 38ms
memory: 3572kb
input:
1000 37 20 2 8 8 7 8 7 4 6 7 4 7 4 8 4 4 5 8 3 5 5 7 7 10 6 3 2 5 3 5 8 3 6 2 4 7 3 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 9 12 4 7 12 6 12 18 11 35 19 3 8 2 6 3 6 4 3 8 4 4 9 26 13 9 9 5 3 4 5 2 10 4 6 6 9 5 3 9 10 6 2 10 4 2 9 9 3 9 3 1 1 1 1 1 1 1 1 1 1 1 1 1 33 18 3 5 3 3 4 1 4 3 1 4 5 1 3 4 ...
output:
0 222 0 18103 0 0 0 12 0 90 0 77 4 0 78 4 5 18 0 576460752303423508 0 47 0 0 2307 85 0 571 352 16 0 39 1 21 186972877292819 1 0 0 5631 795 0 231 0 0 1615 0 0 0 0 0 91 0 5 9 13 264 493 156 0 0 29 0 8191 0 138 0 1 0 0 120475613741931 100 0 0 136 98 160 0 0 3 149 0 0 1593 0 0 10532 2437 0 0 1 52 50 0 1...
result:
wrong answer 20th lines differ - expected: '11', found: '576460752303423508'