QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#208843 | #6769. Monster Hunter | ucup-team1004 | WA | 1ms | 3932kb | C++14 | 1.6kb | 2023-10-09 21:20:03 | 2023-10-09 21:20:03 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<typename T>
ostream& operator << (ostream &out,const vector<T>&x){
if(x.empty())return out<<"[]";
out<<'['<<x[0];
for(int len=x.size(),i=1;i<len;i++)out<<','<<x[i];
return out<<']';
}
template<typename T>
vector<T> ary(const T *a,int l,int r){
return vector<T>{a+l,a+1+r};
}
template<typename T>
void debug(T x){
cerr<<x<<'\n';
}
template<typename T,typename ...S>
void debug(T x,S ...y){
cerr<<x<<' ',debug(y...);
}
const int N=1e5+10;
int T,n,m,a[N],b[N],c[N];
bool chk(ll mid){
copy(b+1,b+1+m,c+1);
ll t1=0,t2=0,t3=0;
for(int i=1;i<=n;i++){
if(a[i]==1)t1+=mid/n+(i<=mid%n);
else if(a[i]==2)t2+=mid/n+(i<=mid%n);
else if(a[i]==3)t3+=mid/n+(i<=mid%n);
}
// debug(t1,t2,t3,ary(c,1,m));
for(int i=1;i<=m&&t3;i++){
if(c[i]>=3&&c[i]%2==1)c[i]-=3,t3--;
}
for(int i=1;i<=m&&t3;i++){
ll x=min(t3/2,1ll*c[i]/6);
t3-=x*2,c[i]-=x*6;
}
for(int i:{5,4,2,1}){
for(int j=1;j<=m&&t3;j++){
if(c[j]==i)c[j]=max(0,c[j]-3),t3--;
}
}
for(int i=1;i<=m&&t2;i++){
ll x=min(t2,1ll*c[i]/2);
t2-=x,c[i]-=x*2;
}
for(int i=1;i<=m&&t2;i++){
if(c[i])c[i]=max(0,c[i]-2),t2--;
}
return accumulate(c+1,c+1+m,0ll)<=t1;
}
void get(){
scanf("%d",&n);
for(int i=1;i<=n;i++)scanf("%d",&a[i]);
scanf("%d",&m);
for(int i=1;i<=m;i++)scanf("%d",&b[i]);
ll l=0,r=2e14,mid;
// chk(r);
for(;l+1<r;){
mid=(l+r)>>1;
if(chk(mid))r=mid;
else l=mid;
}
printf("%lld\n",r);
}
int main(){
for(scanf("%d",&T);T--;)get();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3932kb
input:
2 2 3 2 3 2 4 2 5 1 2 3 2 1 2 3 3
output:
4 3
result:
ok 2 lines
Test #2:
score: 0
Accepted
time: 1ms
memory: 3804kb
input:
100 21 1 3 3 3 2 3 3 2 2 1 3 2 1 3 2 1 1 1 3 3 3 3 3 3 1 19 1 3 1 1 3 3 1 3 2 3 2 2 3 3 1 1 2 2 2 10 2 2 3 1 5 2 2 5 5 3 8 1 3 3 1 3 2 3 1 3 1 2 1 27 1 1 1 2 1 3 1 2 2 3 3 3 1 1 1 1 2 1 2 2 2 2 3 2 1 3 2 4 5 1 2 2 23 2 1 3 2 3 2 2 3 1 2 1 3 1 2 3 1 3 1 2 2 2 1 1 10 4 3 5 4 5 4 1 4 3 4 8 1 2 1 3 2 3 ...
output:
3 15 3 7 19 12 3 8 7 20 5 10 6 10 3 10 16 1 5 6 10 14 13 8 8 5 13 15 5 10 16 14 10 1 10 4 3 16 5 4 7 8 7 5 13 10 10 10 14 3 9 8 19 16 8 25 11 21 2 3 14 12 4 12 17 22 11 3 14 15 2 9 12 7 3 9 4 9 11 2 2 5 5 3 2 2 4 6 7 10 3 14 2 1 5 4 8 13 14 16
result:
ok 100 lines
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3860kb
input:
100 22 3 3 3 1 3 2 3 3 3 3 2 2 3 3 1 2 1 2 3 2 3 1 3 10 1 8 11 1 3 2 1 3 3 1 1 1 1 1 3 3 5 13 21 3 1 2 3 2 1 2 1 3 2 2 1 1 1 1 3 2 3 2 3 2 4 1 5 7 10 8 2 1 3 3 2 2 2 2 3 8 11 8 4 2 1 1 2 2 12 8 26 1 2 3 3 1 2 2 2 2 1 3 1 3 2 1 2 1 3 2 1 1 3 2 3 3 2 4 8 6 5 13 30 1 1 3 2 2 1 2 3 1 3 3 2 3 2 2 3 1 2 3...
output:
8 13 12 13 13 17 11 7 6 23 5 5 12 20 2 22 9 10 3 4 23 12 10 5 9 5 11 17 1 20 9 26 8 13 14 10 13 9 17 5 8 11 17 18 18 16 5 19 8 2 13 20 9 8 19 14 16 12 20 20 9 24 9 16 8 5 5 23 1 4 9 10 10 15 7 11 10 2 8 3 4 18 26 10 9 8 11 5 8 6 9 7 22 2 10 22 16 20 14 13
result:
wrong answer 21st lines differ - expected: '22', found: '23'