QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#200676#5123. Streets275307894aTL 1ms4344kbC++141.5kb2023-10-04 18:21:442023-10-04 18:21:44

Judging History

你现在查看的是最新测评结果

  • [2023-10-04 18:21:44]
  • 评测
  • 测评结果:TL
  • 用时:1ms
  • 内存:4344kb
  • [2023-10-04 18:21:44]
  • 提交

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;
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]);
	int Mi=1e9+7;for(i=1e5;~i;i--) if(f[i]<=1e8) X[++Xh]=make_pair(i,f[i]),Mi=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]);
	Mi=1e9+7;for(i=1e5;~i;i--) if(f[i]<=1e8) Y[++Yh]=make_pair(i,f[i]),Mi=f[i];
	while(T--){
		ll x;scanf("%lld",&x);ll ans=0;
		for(i=1;i<=Xh;i++) for(j=1;j<=Yh;j++) if(1ll*X[i].fi*Y[j].se+1ll*X[i].se*Y[j].fi<=x) ans=max(ans,1ll*X[i].fi*Y[j].fi);
		printf("%lld\n",ans);
	}
}
int main(){
	int t=1;
	// scanf("%d",&t);
	while(t--) Solve();
	cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 4344kb

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
Time Limit Exceeded

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:


result: