洗衣和烘干是可以独立考虑的,先计算出n件衣服的最小洗完时间。,然后再让最后洗好的衣服用最快的烘干机 烘干。
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 1e6 + 10;
#define fi first
#define se second
#define pb push_back
#define wzh(x) cerr<<#x<<'='<<x<<endl;
int T,l,n,m,cas;
LL t[N];
int main() {
for(scanf("%d",&T),cas=1;cas<=T;cas++){
scanf("%d%d%d",&l,&n,&m);
priority_queue<pair<LL,int> >Q;
for(int i=1;i<=n;i++){
int x;
scanf("%d",&x);
Q.push({-x,-x});
}
for(int i=1;i<=l;i++){
auto x=Q.top();Q.pop();
t[i]=-x.fi;
Q.push({x.se+x.fi,x.se});
}
while(!Q.empty())Q.pop();
for(int i=1;i<=m;i++){
int x;
scanf("%d",&x);
Q.push({-x,-x});
}
LL ans=0;
for(int i=l;i>=1;i--){
auto x=Q.top();Q.pop();
ans=max(ans,t[i]-x.fi);
Q.push({x.fi+x.se,x.se});
}
printf("Case #%d: %lld\n",cas,ans);
}
return 0;
}