QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#147431#6632. Minimize Medianqzez#WA 74ms6020kbC++141.5kb2023-08-23 08:58:492023-08-25 01:30:27

Judging History

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

  • [2023-08-25 01:30:27]
  • 评测
  • 测评结果:WA
  • 用时:74ms
  • 内存:6020kb
  • [2023-08-23 08:58:49]
  • 提交

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=1e6+5,M=(1<<15)+5,K=14348907+5,mod=998244353,Mod=mod-1;const db eps=1e-9;const ll INF=1e18+7;mt19937 rnd(time(0));
int n,m,k,A[N];ll w[N];
pair<int,ll> B[100];int Bh;
int CK(int mid){
	ll tot=0;
	for(int i=1;i<=(n+1)/2;i++){
		if(mid==0) tot+=w[A[i]+1];
		else tot+=w[(A[i]+mid-1)/mid];
	}
	// cerr<<mid<<' '<<tot<<'\n';
	return tot<=k;
}
void Solve(){
	int i,j,h;scanf("%d%d%d",&n,&m,&k);
	for(i=1;i<=n;i++) scanf("%d",&A[i]);
	for(i=1;i<=m;i++) scanf("%lld",&w[i]);w[1]=0;
	sort(A+1,A+n+1);w[m+1]=INF;
	ll Mi=INF;int R=m+1;
	for(i=2;i<=m;i++){
		if(1ll*i*i>m){
			Mi=min(Mi,w[i]);
			R=min(R,i);
			while(1ll*R*i>m) Mi=min(Mi,w[R]),R--;
		} 
		for(j=1;j<=R;j++) w[j*i]=min(w[j*i],w[j]+w[i]);
		w[m+1]=min(w[m+1],Mi+w[i]);
	}
	for(i=m;i;i--) w[i]=min(w[i],w[i+1])/*,cerr<<w[i]<<' '*/;
	int l=-1,r=m+1,mid;
	while(l+1<r) mid=l+r>>1,(CK(mid)?r:l)=mid;
	printf("%d\n",r);
}
int main(){
	int t;
	scanf("%d",&t);
	// t=1;                                                                                       
	while(t--) Solve();
	cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}

详细

Test #1:

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

input:

3
3 5 0
2 5 2
3 2 4 6 13
3 5 3
2 5 3
3 2 4 6 13
3 5 6
2 5 2
3 2 4 6 13

output:

2
2
1

result:

ok 3 number(s): "2 2 1"

Test #2:

score: -100
Wrong Answer
time: 74ms
memory: 5896kb

input:

100000
5 10 5
3 7 1 10 10
11 6 11 6 1 8 9 1 3 1
5 6 51
2 2 2 5 1
42 61 26 59 100 54
5 10 76
7 5 8 4 7
97 4 44 83 61 45 24 88 44 44
5 8 90
1 1 5 1 3
35 15 53 97 71 83 26 7
5 3 52
1 1 3 1 1
22 6 93
5 6 28
6 6 1 3 1
9 31 2 19 10 27
5 8 31
3 6 2 1 2
32 29 13 7 57 34 9 5
5 6 75
3 3 4 5 4
40 56 38 60 17 3...

output:

0
2
0
0
0
0
0
0
3
4
0
0
0
0
1
1
0
0
0
0
1
1
0
2
2
0
0
0
0
0
2
0
0
0
2
2
0
1
0
0
0
0
1
0
2
4
1
1
0
0
2
0
0
7
0
2
0
0
0
1
1
0
1
0
1
0
0
2
1
0
6
3
0
0
1
0
2
0
0
3
0
1
0
1
0
2
0
0
0
0
1
2
2
4
0
0
0
0
0
0
1
2
2
1
2
2
0
1
1
0
0
0
0
0
1
2
1
4
1
0
4
1
2
1
0
0
0
0
1
2
1
0
0
2
3
1
0
1
1
1
0
1
5
0
1
2
0
2
0
0
...

result:

wrong answer 56th numbers differ - expected: '1', found: '2'