QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#200759 | #5123. Streets | 275307894a | WA | 594ms | 10952kb | C++14 | 2.3kb | 2023-10-04 19:35:12 | 2023-10-04 19:35:12 |
Judging History
answer
#include<bits/stdc++.h>
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;using LL=__int128;
const int N=1e5+5,M=2.1e4+5,K=600+5,mod=1e9+7,Mod=mod-1;const db eps=1e-9;const int INF=1e9+7;mt19937 rnd(263082);
int n,m,T,A[N],B[N],f[N];
pii X[N],Y[N];int Xh,Yh;
int fa[N];
int GF(int x){return fa[x]^x?fa[x]=GF(fa[x]):x;}
vector<int> S[N];int pre[N];
ll C;
void Add(int x){
int y=GF(x-1);if(!y) return;
if(X[x].se*1.0/X[x].fi>=X[y].se*1.0/X[y].fi) return;
db w=(C*1.0/X[y].fi-C*1.0/X[x].fi)/(X[y].se*1.0/X[y].fi-X[x].se*1.0/X[x].fi);
if(w>Y[Yh].fi) return;
S[pre[(int)ceil(w)]].emplace_back(x);
}
void Solve(){
int i,j;scanf("%d%d%d",&n,&m,&T);
for(i=1;i<=n;i++) scanf("%d",&A[i]);for(i=1;i<=n;i++) scanf("%d",&B[i]);
Me(f,0x3f);for(i=1;i<=n;i++) for(j=i;j<=n;j++) f[A[j]-A[i]]=min(f[A[j]-A[i]],B[i]+B[j]);
for(i=1;i<=1e5;i++) if(f[i]<=1e8) X[++Xh]=make_pair(i,f[i]);
for(i=1;i<=m;i++) scanf("%d",&A[i]);for(i=1;i<=m;i++) scanf("%d",&B[i]);
Me(f,0x3f);for(i=1;i<=m;i++) for(j=i;j<=m;j++) f[A[j]-A[i]]=min(f[A[j]-A[i]],B[i]+B[j]);
for(i=1;i<=1e5;i++) if(f[i]<=1e8) Y[++Yh]=make_pair(i,f[i]);
cerr<<Xh<<' '<<Yh<<'\n';
for(i=1;i<=Yh;i++) fill(pre+Y[i-1].fi+1,pre+Y[i].fi+1,i);
while(T--){
scanf("%lld",&C);ll ans=0;
iota(fa+1,fa+Xh+1,1);for(i=1;i<=Yh;i++) S[i].clear();
for(i=2;i<=Xh;i++) Add(i);
for(i=1;i<=Yh;i++) {
for(int j=0;j<S[i].size();j++){
int p=S[i][j];
int y=GF(p-1);if(!y) continue;
if(C*1.0/X[y].fi-i*1.0*X[y].se/X[y].fi>C*1.0/X[p].fi-i*1.0*X[p].se/X[p].fi) continue;
fa[y]=y-1;Add(p);
}
int l=0,r=Xh+1,mid;
while(l+1<r) mid=l+r>>1,(!GF(mid)||(C-1ll*Y[i].fi*X[GF(mid)].se)*1.0/X[GF(mid)].fi>=Y[i].se?l:r)=mid;
if(GF(l)) ans=max(ans,1ll*Y[i].fi*X[GF(l)].fi)/*,cerr<<Y[i].fi<<' '<<X[GF(l)].fi<<'\n'*/;
}
printf("%lld\n",ans);
if(T==80) exit(0);
}
}
int main(){
int t=1;
// scanf("%d",&t);
while(t--) Solve();
cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 8516kb
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: 594ms
memory: 10952kb
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 9897364060 2092356842 9518949154 5456172288 9986903784 9740388672 9518949154 8468005000 8563940714 9235585392 6867733792 8462308998 8464111740 9920856612 9560740800 9471281534 9233615512 8429746248 8568584024
result:
wrong answer 2nd numbers differ - expected: '9941157660', found: '9897364060'