前言
今天早上贼颓。。
显示去poj看错了一题,然后poj还炸裂了评测不了。。
然后做这题又看错了,想了半天。。
然后想出一点点东西的时候发现看错题了QAQ
于是一早上就荒废了。。
感觉这是退役的节奏啊
题解
ORZ
膜的这个人。。根据挺牛逼的模拟题。。
我就懒得写了
不要打死我
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int N=100005;
int n,m,x;
struct qq
{
int cnt,id;//这个东西可以被喝多少次 这是哪一个瓶子
}s[N];
bool cmp (qq a,qq b){return a.cnt==b.cnt?a.id>b.id:a.cnt<b.cnt;}
int w=0;
int f[N];
int lb (int x){return x&(-x);}
void add (int x,int y)
{
while (x<=n)
{
f[x]+=y;
x+=lb(x);
}
}
int get (int x)
{
int lalal=0;
while (x>=1)
{
lalal+=f[x];
x-=lb(x);
}
return lalal;
}
int ans=0;
int shen=0,now=0;
int find (int x)
{
int ans1=now;
int l=now,r=n;
while (l<=r)
{
int mid=(l+r)>>1;
if (get(mid)-get(now)<=x)
{
ans1=mid;
l=mid+1;
}
else r=mid-1;
}
return ans1;
}
void solve ()
{
for (int u=1;u<=w;u++)
{
if (s[u].cnt<ans)
{
add(s[u].id,-1);
continue;
}
while (shen<m&&ans+(get(n)-get(now))<=s[u].cnt)//这个点现在还不会GG
{
int lalal=get(n)-get(now);
ans+=lalal;
now=0;
shen++;
}
if (shen>=m) break;
int ooo=find(s[u].cnt-ans);
now=ooo;
ans=s[u].cnt;
add(s[u].id,-1);
}
}
int main()
{
scanf("%d%d%d",&n,&m,&x);
for (int u=1;u<=n;u++)
{
scanf("%d",&s[u].cnt);
s[u].id=u;
}
for (int u=1;u<=n;u++)
{
int w;
scanf("%d",&w);
s[u].cnt=(x-s[u].cnt)/w+1;
}
w=0;
for (int u=1;u<=n;u++)
{
if (s[u].cnt>0)
{
s[++w]=s[u];
add(s[u].id,1);
}
}
sort(s+1,s+1+w,cmp);
solve();
printf("%d\n",ans);
return 0;
}