21 solutions

  • 5
    @ 2025-3-28 17:36:39
    #include<bits/stdc++.h>
    using namespace std;
    int main(){
    	int n,m;
    	cin>>n>>m;
    	cout<<n*m;
      return 0;
    }
    
    
    • 3
      @ 2026-3-25 18:14:56

      @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

      • 2
        @ 2026-5-12 18:18:42

        给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外) 给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外)

      • 1
        @ 2026-6-9 18:14:28

        这里已经变成不稳定SMP了知道吗? 等会温布来放轨道打击炮就完了,先跑了

        • 1
          @ 2026-6-3 17:23:20
          //P2376
          #include<bits/stdc++.h>
          using namespace std;
          struct node{
          	int x,t;
          };
          int main(){
          	int n,m;
          	cin>>n>>m;
          	vector<node> v(n+m+5);
          	for(int i=1;i<=n+m;i++) cin>>v[i].x;
          	for(int i=1;i<=n+m;i++) cin>>v[i].t;
          	vector<int> c(m+5),u(n+5);
          	int cn1=0,cn2=0;
          	for(int i=1;i<=n+m;i++){
          		if(v[i].t==1) c[++cn1]=v[i].x;
          		else u[++cn2]=v[i].x;
          	}
          	vector<int> arr(m+3);
          	for(int i=1;i<=n;i++){
          		int minn=1,minx=INT_MAX;
          		for(int j=1;j<=m;j++){
          			if(abs(u[i]-c[j])<=minx){
          				if(abs(u[i]-c[j])==minx){
          					if(j<minn){
          						minx=abs(u[i]-c[j]);
          						minn=j;
          					}
          				}
          				else if(abs(u[i]-c[j])<minx){
          					minx=abs(u[i]-c[j]);
          					minn=j;
          				}
          			}
          		}
          		arr[minn]++;
          	}
          	for(int i=1;i<=m;i++){
          		cout<<arr[i]<<" ";
          	}
          	return 0;
          }
          
          • 1
            @ 2026-5-12 18:16:36

            给我点赞的父母平安,天天发财,考上清北,绝对有效!!!(lqst2502除外)

            • 1
              @ 2026-4-1 16:58:47
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              #include<bits/stdc++.h>
              #define int long long
              using namespace std;
              const int N=1e6+10;
              int a[N],b[N];
              void solve() 
              {
                  priority_queue<int,vector<int>,greater<int>>q;
              	int n,m,k;
              	cin>>n>>m>>k;
              	for(int i=1;i<=n;i++)
              	{
              		cin>>a[i];
              	}
              	for(int i=1;i<=n;i++)
              	{
              		if(k>0)
              		{
              			k--;
              			q.push(a[i]);
              		}
              		else
              		{
              			if(q.size()&&q.top()<a[i])
              			{
              				m-=q.top();
              				q.pop();
              				q.push(a[i]);
              			}
              			else
              			{
              				m-=a[i];
              			}
              		}
              		if(m<=0)
              		{
              			cout<<i-1<<endl;
              			return;
              		}
              	}
              	cout<<n<<endl;
              }
              signed main() 
              {
              	//freopen("spire.in","r",stdin);
              	//freopen("spire.out","w",stdout);
              	cin.tie(0)->sync_with_stdio(0);
              	cout.tie(0);
              	int T;
              	cin>>T;
              	while(T--)  
              	{
              		solve();
              	}
              	return 0;
              }
              
              
              
              • 1

                #include<bits/stdc++.h> using namespace std; int main(){ int n,m; cin>>n>>m; cout<<n*m; return 0; }

                • 0
                  @ 2026-6-3 17:31:59
                  //J123
                  #include<bits/stdc++.h>
                  using namespace std;
                  struct node{
                  	int x,t;
                  };
                  int main(){
                  	int n,m;
                  	cin>>n>>m;
                  	vector<node> v(n+m+5);
                  	for(int i=1;i<=n+m;i++) cin>>v[i].x;
                  	for(int i=1;i<=n+m;i++) cin>>v[i].t;
                  	vector<int> c(m+5),u(n+5);
                  	int cn1=0,cn2=0;
                  	for(int i=1;i<=n+m;i++){
                  		if(v[i].t==1) c[++cn1]=v[i].x;
                  		else u[++cn2]=v[i].x;
                  	}
                  	vector<int> arr(m+3);
                  	for(int i=1;i<=n;i++){
                  		int minn=1,minx=INT_MAX;
                  		for(int j=1;j<=m;j++){
                  			if(abs(u[i]-c[j])<=minx){
                  				if(abs(u[i]-c[j])==minx){
                  					if(j<minn){
                  						minx=abs(u[i]-c[j]);
                  						minn=j;
                  					}
                  				}
                  				else if(abs(u[i]-c[j])<minx){
                  					minx=abs(u[i]-c[j]);
                  					minn=j;
                  				}
                  			}
                  		}
                  		arr[minn]++;
                  	}
                  	for(int i=1;i<=m;i++){
                  		cout<<arr[i]<<" ";
                  	}
                  	return 0;
                  }
                  
                  • 0
                    @ 2026-4-1 16:57:48
                    #include<bits/stdc++.h>
                    #define int long long
                    using namespace std;
                    const int N=1e6+10;
                    int a[N],b[N];
                    void solve() 
                    {
                        priority_queue<int,vector<int>,greater<int>>q;
                    	int n,m,k;
                    	cin>>n>>m>>k;
                    	for(int i=1;i<=n;i++)
                    	{
                    		cin>>a[i];
                    	}
                    	for(int i=1;i<=n;i++)
                    	{
                    		if(k>0)
                    		{
                    			k--;
                    			q.push(a[i]);
                    		}
                    		else
                    		{
                    			if(q.size()&&q.top()<a[i])
                    			{
                    				m-=q.top();
                    				q.pop();
                    				q.push(a[i]);
                    			}
                    			else
                    			{
                    				m-=a[i];
                    			}
                    		}
                    		if(m<=0)
                    		{
                    			cout<<i-1<<endl;
                    			return;
                    		}
                    	}
                    	cout<<n<<endl;
                    }
                    signed main() 
                    {
                    	//freopen("spire.in","r",stdin);
                    	//freopen("spire.out","w",stdout);
                    	cin.tie(0)->sync_with_stdio(0);
                    	cout.tie(0);
                    	int T;
                    	cin>>T;
                    	while(T--)  
                    	{
                    		solve();
                    	}
                    	return 0;
                    }
                    
                    
                    • -1
                      @ 2026-3-26 11:30:38

                      @ 刘丛睿 (lqst2025013) @ 刘丛睿 (lqst2025013) @ 刘丛睿 (lqst2025013) @ 刘丛睿 (lqst2025013) @ 刘丛睿 (lqst2025013) @ 刘丛睿 (lqst2025013) @ 刘丛睿 (lqst2025013) @ 刘丛睿 (lqst2025013) @ 刘丛睿 (lqst2025013) @ 刘丛睿 (lqst2025013) @ 刘丛睿 (lqst2025013) @ 刘丛睿 (lqst2025013) @ 刘丛睿 (lqst2025013) @ 刘丛睿 (lqst2025013) @ 刘丛睿 (lqst2025013) @ 刘丛睿 (lqst2025013) @ 刘丛睿 (lqst2025013) @ 刘丛睿 (lqst2025013) @ 刘丛睿 (lqst2025013) @ 刘丛睿 (lqst2025013) @ 刘丛睿 (lqst2025013) @ 刘丛睿 (lqst2025013) @ 刘丛睿 (lqst2025013) @ 刘丛睿 (lqst2025013) @ 刘丛睿 (lqst2025013) @ 刘丛睿 (lqst2025013) @ 刘丛睿 (lqst2025013) @ 刘丛睿 (lqst2025013) @ 刘丛睿 (lqst2025013) @ 刘丛睿 (lqst2025013) @ 刘丛睿 (lqst2025013) @ 刘丛睿 (lqst2025013)

                      • -1
                        @ 2025-12-3 16:39:00

                        #include<bits/stdc++.h> using namespace std; int main(){ int n,m; cin>>n>>m; cout<<n*m; return 0; }

                        • -1
                          @ 2025-12-3 16:38:43

                          #include using namespace std; int main(){

                          return 0;
                          

                          }

                          • -1
                            @ 2025-12-1 17:12:49

                            #include<bits/stdc++.h> using namespace std; int main(){ int a,b; cin>>a>>b; cout<<a*b; return 0; }

                            • -1
                              @ 2025-11-5 10:54:12

                              这是一道非常简单的题,先看题目: 我们知道了同学数量和每个同学需要苹果的数量,那么:

                              • -1

                                #include<bits/stdc++.h> using namespace std; int main(){ int n,m; cin>>n>>m; cout<<n*m; return 0; }

                                • -4
                                  @ 2026-1-14 18:00:10

                                  You son of a bitch. 翻译:你是天才

                                  • -4
                                    @ 2025-12-23 17:38:53

                                    #include<bits/stdc++.h> using namespace std; int main(){ int n,m; cin>>n>>m; cout<<n*m; return 0; }

                                    • -4
                                      @ 2025-12-23 17:38:44

                                      #include<bits/stdc++.h> using namespace std; int main(){ int n,m; cin>>n>>m; cout<<n*m; return 0; }

                                      • -4
                                        @ 2025-12-20 16:10:24

                                        #include<bits/stdc++.h> using namespace std; int n,m; int main(){ cin>>n>>m; cout<<n*m; return 0; }

                                        Information

                                        ID
                                        1324
                                        Time
                                        1000ms
                                        Memory
                                        256MiB
                                        Difficulty
                                        3
                                        Tags
                                        (None)
                                        # Submissions
                                        252
                                        Accepted
                                        128
                                        Uploaded By