QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#108810 | #5123. Streets | shenxinge | WA | 836ms | 12548kb | C++23 | 1.4kb | 2023-05-26 18:02:44 | 2023-05-26 18:02:46 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
constexpr int maxn(1e5+10),maxe(1e5),inf(1e9+7);
int n,m,T,X[maxn],Y[maxn],A[maxn],B[maxn],va[maxn],vb[maxn],f[maxn][21],st[maxn],top,mx;long long c;
inline long long F(int i,int j){return 1ll*i*vb[j]+1ll*j*va[i];}
inline bool check(int x,int y){
for(int i=19;i>0;i--) if(f[f[y][i]][0]&&F(x,f[f[y][i]][0])<=F(x,f[y][i])) y=f[y][i];
if(y^mx&&F(x,f[y][0])<=c) return true; return F(x,y)<=c;
}
signed main(){
ios::sync_with_stdio(false),cin.tie(nullptr);
cin >> n >> m >> T;for(int i=1;i<=maxe;i++) va[i]=vb[i]=inf;
for(int i=1;i<=n;i++) cin >> X[i];for(int i=1;i<=n;i++) cin >> A[i];
for(int i=1;i<=m;i++) cin >> Y[i];for(int i=1;i<=m;i++) cin >> B[i];
for(int i=1;i<n;++i) for(int j=i+1;j<=n;++j) va[X[j]-X[i]]=min(va[X[j]-X[i]],A[i]+A[j]);
for(int i=1;i<m;++i) for(int j=i+1;j<=m;++j) vb[Y[j]-Y[i]]=min(vb[Y[j]-Y[i]],B[i]+B[j]);
for(int i=maxe;i;i--) if(vb[i]<inf){
while(top>1&&(vb[st[top]]-vb[i])*1ll*(st[top-1]-st[top])>=(vb[st[top-1]]-vb[st[top]])*1ll*(st[top]-i)) top--;
if(!top) mx=i; else f[i][0]=st[top]; st[++top]=i;
}
for(int i=1;i<20;i++) for(int u=1;u<=maxe;u++) f[u][i]=f[f[u][i-1]][i-1];
while(T--){cin >> c;long long ans=0;
for(int i=maxe,p=1;i;i--) if(va[i]!=inf) while(true){
while(p<=mx&&vb[p]==inf) p++; if(p<=mx&&check(i,p)) ans=max(ans,1ll*i*(p++)); else break;
}cout << ans << '\n';
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 9ms
memory: 12548kb
input:
3 4 20 1 3 4 3 1 2 1 3 4 7 4 2 1 2 1 5 6 7 9 10 11 12 15 16 17 22 23 28 30 35 43 47 49 57
output:
0 0 1 1 1 2 2 3 3 4 4 6 6 9 9 12 12 12 18 18
result:
ok 20 numbers
Test #2:
score: -100
Wrong Answer
time: 836ms
memory: 12444kb
input:
4995 4998 100 4 7 20 34 44 100 102 130 175 198 205 250 257 259 267 278 300 324 337 346 353 364 403 427 439 440 451 523 532 534 555 599 634 639 756 802 805 825 855 859 890 905 912 915 953 989 1014 1031 1052 1059 1097 1124 1183 1216 1297 1308 1337 1342 1361 1392 1400 1421 1451 1471 1523 1537 1542 1619...
output:
9991201920 9846268520 907122720 8760174885 6060506760 9937098864 9829578925 8760174885 7574925510 4509455216 6775313892 2333101785 5640051048 8604521982 9847464968 8760672560 8729195013 8602353132 8635059390 4509455216 1009903314 6527370960 9801310985 2333101785 5841754098 8602353132 1714259040 6697...
result:
wrong answer 2nd numbers differ - expected: '9941157660', found: '9846268520'