Source Code
#include <iostream>
#include<map>
#include<algorithm>
using namespace std ;

int main ()
{
  long long n,s , temp , cnt = 0;
  cin>>n>>s;
  int t[n] , r[n];
  for(int i =0 ; i<n;i++)cin>>t[i];
  for(int i =0 ; i<n;i++)cin>>r[i];
  for(int i =0 ;i<n; i++)
  {
    for(int j=0; j<n-1;j++)
    {
      if(t[j]>t[j+1])
      {
        swap(t[j],t[j+1]);
        swap(r[j],r[j+1]);
      }
    }
  }
for(int i=n-1;i>=0;i--)
{

  
  s-=t[i];
   if(s<=0)break;
  s+=r[i];
  cnt ++;
  
}
cout<<cnt;
}
Copy
Wheatly's portals - Hard version Tala_Ibraheem
GNU G++17
2 ms
228 KB
Wrong Answer