oxygen cylinder management program in java
/* Oxygen Cylinders Management You are the given a list of covid patients where paitent[i] is the required by the ith patient, and there are enough cylinders where each cylinder contains a limited amount of oxygen. Each cylinder can serve at most two patients at the same time, provided the array of the oxgen required by the patients and cylinder capacity. */ import java.util.Scanner; public class Main{ static int numOxygenCylinder(int[] oxyegen, int limit){ int sum =0; for(int i : oxyegen){ sum+=i; } if(sum%limit == 0) return sum/limit; else return (sum/limit)+1; } public static void main(String[] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int limit = sc.nextInt(); int[] oxygen = new int[n]; for(int i=0; i<n; i++) oxygen[i] = sc.nextInt(); System.out.println(numOxygenCylinder(oxygen, limit)); } }