#include <stdio.h>
#include <stdlib.h>

typedef struct {
    int min_oxygen;
    int change;
} Station;

// Compare function for qsort
int compare(const void *a, const void *b) {
    Station *first_station = (Station *)a;
    Station *second_station = (Station *)b;
    return first_station->min_oxygen - second_station->min_oxygen;
}

// Function to check if it’s possible to visit all chambers
int canVisitAllStations(Station stations[], int num_stations, int initial_oxygen) {
    // First, sort the stations based on their minimum oxygen requirement
    qsort(stations, num_stations, sizeof(Station), compare);

    // Traverse through all stations
    for (int i = 0; i < num_stations; ++i) {
        // Check if there’s enough oxygen to visit the station
        if (initial_oxygen >= stations[i].min_oxygen) {
            // Update the oxygen level based on the station’s change
            initial_oxygen += stations[i].change;
        } else {
            // Not enough oxygen to visit the station
            return 0; // Returning 0 indicates “NO”
        }
    }
    // If we’ve successfully iterated through all stations
    return 1; // Returning 1 indicates “YES”
}

int main() {
    int num_stations, initial_oxygen;
    scanf("%d %d", &num_stations, &initial_oxygen);

    Station stations[num_stations];

    // Reading minimum oxygen and change for each station
    for (int i = 0; i < num_stations; ++i) {
        scanf("%d", &stations[i].min_oxygen);
    }
    for (int i = 0; i < num_stations; ++i) {
        scanf("%d", &stations[i].change);
    }

    // Determine if it’s possible to visit all stations
    if (canVisitAllStations(stations, num_stations, initial_oxygen)) {
        printf("YES\n");
    } else {
        printf("NO\n");
    }

    return 0;
}

correct this code to give
Problem Statement
Luckily Percy made it safely to the caves located deep on the ocean floor. Now he gets to explore the various chambers present there. However, he again has an oxygen issue. As per safety guidelines, each chamber has a certain minimum oxygen level limit that the diver needs to have before entering it. At the same time, after visiting each chamber, Percy either loses certain amount of oxygen (due to consumption) or ends up gaining some (due to presence of air pockets). Percy is curious and wants to know whether it will be possible for him to visit all the chambers without running out of oxygen.

Percy initially starts with 
 amount of oxygen. There are 
 chambers, where the 
th chamber has a minimum oxygen requirement of 
i and after visiting the chamber, his oxygen level changes by 
i amount.

You have to help Percy again by letting him know whether it is possible for him to visit all the chambers in any order without running out of oxygen. He can visit one chamber only once.

Input Format
The first line of input contains integers 
 and 
, denoting the number of chambers and the initial oxygen supply respectively.

The second line contains 
 integers representing the minimum oxygen requirement 
i of each chamber.

The third line contains 
 integers representing the changee 
i in oxygen level after Percy visits a chamber.

Constraints
There are two sets of constraints, which differ only in the range of 
. The points of this question are split based on the value of this range.

Set 1


i 

i 

Set 2


i 

i 

Output Format
You need to output "YES" or "NO" (case sensitive) based on whether it is possible for him to visit all the chambers or not.

Sample Test Case 1:
Input:
Copy
3 5
3 6 1
-4 -3 6
Output:
Copy
YES
Explanation:
Percy wants to visit all the 
 chambers. He initially has 
 units of oxygen. He goes to the first chamber and is left with 
 unit. Then he goes to the third chamber and is left with 
 units. Lastly, he visits the second chamber and is left with 
 units of oxygen.

Sample Test Case 2:
Input:
Copy
2 7
7 3
-4 -3
Output:
Copy
YES
Explanation:
Percy wants to visit all the 
 chambers. He initially has 
 units of oxygen. He goes to the first chamber and is left with 
 units. Then he visits the second chamber and is left with 
 units of oxygen.

Sample Test Case 3:
Input:
Copy
2 5
2 2
-3 -4
Output:
Copy
NO
Explanation:
Percy wants to visit all the 
 chambers. He initially has 
 units of oxygen. One way he can try is going to the first chamber in the first go and be left with 
 units, with which he can enter the second chamber, but then run out of oxygen. The other way is he can go to second chamber in the first attempt, but this leaves him with only 
 unit afterwards, with which he cannot enter the first chamber.