#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define Maxn 100020
char *p1,*p2,buf[100000];
#define nc() (p1==p2 && (p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++)
inline int read() // 快速模板
{
int x=0,f=1;
char ch=nc();
while(ch<48||ch>57)
{
if(ch=='-')
f=-1;
ch=nc();
}
while(ch>=48&&ch<=57)
x=x*10+ch-48,ch=nc();
return x*f;
}
ll cost[Maxn],level[Maxn];
int main() {
ll a,b,n,t,a1=0,a2=0,t1,t2;
n = read(),t=read();
a = read(),b=read();
for(int i=1;i<=n;++i)
cost[i] = read();
for(int i=1;i<=n;++i)
level[i] = read();
t1 = t2 = t;
for(int i=1;i<=n;++i)
{
if(level[i]>=b) //检查难度
{
if(t2 >=(cost[i]<<1)) //剩余时间足够
{
++a2;
t2 -= cost[i]<<1; //时间翻倍
}
}
else {
if(t2>=cost[i])
{
++a2;
t2 -= cost[i];
}
}
if(level[i]>=a)
continue;
if(t1<cost[i])
continue;
//clccle能刷这道题
++a1;
t1 -= cost[i];
}
cout<<a1<<' '<<a2; //clccle和rqy的刷题数
}
用t1,a1和t2,a2分别维护两人的剩余时间和已刷题数量,然后按题意模拟即可

京公网安备 11010502036488号