QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#147423 | #6632. Minimize Median | qzez# | WA | 167ms | 8120kb | C++14 | 1.6kb | 2023-08-23 08:37:46 | 2023-08-25 01:29:41 |
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=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],w[N];ll f[N];
pair<int,ll> B[100];int Bh;
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("%d",&w[i]);
sort(A+1,A+n+1);fill(f,f+m+1,0);
for(i=1;i<=(n+1)/2;i++){
Bh=0;
if(m==2){
for(int j=0;j<=20;j++) B[++Bh]=make_pair(A[i]>>j,1ll*w[2]*j);
}else{
for(int x=0;x<3;x++){
int p=A[i]>>x;
for(int y=0;y<=13;y++) B[++Bh]=make_pair(p,1ll*x*w[2]+1ll*y*w[3]),p/=3;
}
}
sort(B+1,B+Bh+1);
f[B[1].fi]+=B[1].se;ll tot=B[1].se;
for(j=2;j<=Bh;j++) if(tot>B[j].se) f[B[j].fi]-=tot,tot=B[j].se,f[B[j].fi]+=tot;
}
for(i=0;i<=m;i++){
if(i) f[i]+=f[i-1];
if(f[i]<=k){printf("%d\n",i);return;}
}
// for(i=1;i<=m;i++) printf("%lld ",f[i]);printf("\n");
printf("%d\n",f[m]);
}
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: 2ms
memory: 8088kb
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: 167ms
memory: 8120kb
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:
7 2 1 0 0 0 1 3 3 4 2 4 1 1 3 1 1 4 0 1 1 1 0 2 2 1 0 3 3 1 6 0 1 6 2 2 2 1 1 3 4 2 2 0 3 4 1 1 2 0 2 0 0 8 5 1 0 0 5 1 1 2 1 4 1 2 1 3 1 1 6 4 0 0 1 0 2 1 0 4 0 2 4 3 3 2 1 0 0 0 4 3 1 4 0 0 4 0 0 0 1 2 2 1 2 2 0 1 1 0 0 0 0 0 4 2 2 4 3 0 4 1 2 1 2 3 2 6 1 2 1 6 2 2 3 1 1 1 1 1 2 1 7 1 1 2 3 2 1 1 ...
result:
wrong answer 1st numbers differ - expected: '0', found: '7'