QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#758072 | #9599. Dragon Bloodline | Maxduan# | WA | 0ms | 3756kb | C++20 | 1.1kb | 2024-11-17 15:34:12 | 2024-11-17 15:34:12 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define maxn 200005
#define int long long
int a[maxn],b[maxn];
int n,m;
bool check(int k){
priority_queue<int>pq;
for(int i=1;i<=n;i++){
pq.push(a[i]*k);
}
for(int i=m-1;i>=0;i--){
int cnt=b[i];
int tmp=(1<<i);
while(pq.size()&&pq.top()>=tmp&&cnt>0){
int now=pq.top();
pq.pop();
int mm=min(now/tmp,cnt);
now-=mm*tmp;
cnt-=mm;
if(now>0)pq.push(now);
}
while(pq.size()&&cnt--){
pq.pop();
}
}
return pq.empty();
}
void solve(){
cin>>n>>m;
for(int i=1;i<=n;i++){
cin>>a[i];
}
for(int i=0;i<m;i++){
cin>>b[i];
}
int l=1,r=1e9;
while(l<=r){
int mid=l+r>>1;
if(check(mid)){
l=mid+1;
}
else{
r=mid-1;
}
}
cout<<l-1<<'\n';
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
int TT=1;cin>>TT;
while(TT--){
solve();
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3756kb
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: -100
Wrong Answer
time: 0ms
memory: 3496kb
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:
1000000000
result:
wrong answer 1st lines differ - expected: '1048575000000000', found: '1000000000'