QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#188439 | #6632. Minimize Median | qzzyq | WA | 29ms | 5716kb | C++14 | 1.7kb | 2023-09-25 20:27:10 | 2023-09-25 20:27:10 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define ull unsigned long long
#define maxn 2000005
#define put() putchar('\n')
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
using namespace std;
void read(int &x){
int f=1;x=0;char c=getchar();
while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
while (c>='0'&&c<='9') {x=x*10+c-'0';c=getchar();}
x*=f;
}
namespace Debug{
Tp void _debug(char* f,Ty t){cerr<<f<<'='<<t<<endl;}
Ts void _debug(char* f,Ty x,Ar... y){while(*f!=',') cerr<<*f++;cerr<<'='<<x<<",";_debug(f+1,y...);}
Tp ostream& operator<<(ostream& os,vector<Ty>& V){os<<"[";for(auto& vv:V) os<<vv<<",";os<<"]";return os;}
#define gdb(...) _debug((char*)#__VA_ARGS__,__VA_ARGS__)
}using namespace Debug;
#define fi first
#define se second
#define mk make_pair
const int mod=1e9+7;
int power(int x,int y=mod-2) {
int sum=1;
while (y) {
if (y&1) sum=sum*x%mod;
x=x*x%mod;y>>=1;
}
return sum;
}
int n,m,k;
int f[maxn],a[maxn];
const int inf=1e9;
bool check(int val) {
int sum=0,i;
for (i=1;i<=n/2+1;i++) if (a[i]>val) sum+=f[(a[i]+val+1)/(val+1)];
// gdb(sum,k);
return sum<=k;
}
void solve(void) {
int i,j,l,r,mid;
read(n);read(m);read(k);
for (i=1;i<=n;i++) read(a[i]);
sort(a+1,a+1+n);
for (i=1;i<=2*m+1;i++) f[i]=inf;
for (i=1;i<=m;i++) read(f[i]);f[1]=0;
for (i=m;i>=1;i--) f[i]=min(f[i],f[i+1]);
m*=2;
for (j=2;j<=m;j++) {
for (i=j;i<=m;i+=j) f[i]=min(f[i],f[i/j]+f[j]);
}
for (i=m;i>=1;i--) f[i]=min(f[i],f[i+1]);//,gdb(i,f[i]);
l=0,r=m+1;
while (l+1<r) {
mid=l+r>>1;
if (check(mid)) r=mid;
else l=mid;
}
printf("%d\n",r);
}
signed main(void){
int T;
read(T);
while (T--) solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 5716kb
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: 29ms
memory: 5660kb
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:
1 2 1 1 1 1 1 1 3 4 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 1 1 1 1 1 2 1 1 1 2 2 1 1 1 1 1 1 1 1 2 4 1 1 1 1 2 1 1 7 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 6 3 1 1 1 1 2 1 1 3 1 1 1 1 1 2 1 1 1 1 1 2 1 4 1 1 1 1 1 1 1 2 2 1 2 2 1 1 1 1 1 1 1 1 1 2 1 4 1 1 4 1 2 1 1 1 1 1 1 2 1 1 1 2 3 1 1 1 1 1 1 1 5 1 1 2 1 2 1 1 ...
result:
wrong answer 1st numbers differ - expected: '0', found: '1'