1 条题解
-
0
#include<bits/stdc++.h> using namespace std; #define int long long const int N=2e5+10; struct nd{int a,b;}c[N]; signed main() { ios::sync_with_stdio(0); cin.tie(0);cout.tie(0); int n,x,y;cin>>n>>x>>y; int ans=n,sum=0,l=0,r=0; for(int i=1;i<=n;i++)cin>>c[i].a; for(int i=1;i<=n;i++)cin>>c[i].b; sort(c+1,c+n+1,[](nd n1,nd n2){return n1.a>n2.a;}); for(int i=1;i<=n;i++) { sum++;l+=c[i].a;r+=c[i].b; if(l>x||r>y)break; } ans=min(ans,sum);sum=l=r=0; sort(c+1,c+n+1,[](nd n1,nd n2){return n1.b>n2.b;}); for(int i=1;i<=n;i++) { sum++;l+=c[i].a;r+=c[i].b; if(l>x||r>y)break; } ans=min(ans,sum);cout<<ans; return 0; }
- 1
信息
- ID
- 1661
- 时间
- 2000ms
- 内存
- 1024MiB
- 难度
- 5
- 标签
- 递交数
- 29
- 已通过
- 14
- 上传者