@@ -0,0 +1,2633 @@
+import java.io.BufferedReader;%0Aimport java.io.BufferedWriter;%0Aimport java.io.FileNotFoundException;%0Aimport java.io.FileReader;%0Aimport java.io.FileWriter;%0Aimport java.io.IOException;%0Aimport java.util.ArrayList;%0A%0Apublic class FullOvation %7B%0A    private int shyMax; // Maximum number of shyness level.%0A    private ArrayList%3CInteger%3E numPersons; // Number of persons with their respective shy level.%0A    private int numPeopleNeeded;%0A%0A    public FullOvation(int shyMax, ArrayList%3CInteger%3E numPersons) %7B%0A        this.shyMax = shyMax;%0A        this.numPersons = numPersons;%0A        this.numPeopleNeeded = 0;%0A    %7D%0A%0A    public void setShyMax(int shyMax) %7B%0A        this.shyMax = shyMax;%0A        this.numPeopleNeeded = 0;%0A    %7D%0A%0A    public void setNumPersons(ArrayList%3CInteger%3E numPersons) %7B%0A        this.numPersons = numPersons;%0A    %7D%0A%0A    public int getNumPeopleNeeded() %7B%0A        return numPeopleNeeded;%0A    %7D%0A%0A    public void calculateNumberOfFriends()%7B%0A        int length = numPersons.size();%0A        int sum = numPersons.get(0);%0A        for(int index = 1; index %3C length; index++)%7B%0A            if((sum + numPeopleNeeded) %3C index)%7B%0A                numPeopleNeeded = index - sum;%0A            %7D%0A            sum += numPersons.get(index);%0A        %7D%0A    %7D%0A%0A    public static void main(String%5B%5D args)%7B%0A        String filename = %22A-large-practice.in%22;%0A        try(BufferedReader br = new BufferedReader(new FileReader(filename)))%7B%0A            String line;%0A            String%5B%5D data;%0A            ArrayList%3CInteger%3E numPeople = new ArrayList%3CInteger%3E();%0A            FullOvation fullOvation = new FullOvation(0, new ArrayList%3CInteger%3E());%0A            BufferedWriter bw = new BufferedWriter(new FileWriter(%22output.out%22));%0A%0A            int T = Integer.parseInt(br.readLine()); // Number of test cases.%0A            int caseNumber = 1;%0A%0A            //while(T-- %3C 0) %7B%0A            while ((line = br.readLine()) != null) %7B%0A                data = line.split(%22 %22);%0A                fullOvation.setShyMax(Integer.parseInt(data%5B0%5D));%0A                data = data%5B1%5D.split(%22%22);%0A                for(String d : data)%0A                    numPeople.add(Integer.parseInt(d));%0A%0A                fullOvation.setNumPersons(numPeople);%0A%0A                fullOvation.calculateNumberOfFriends();%0A                bw.write(%22Case #%22 + caseNumber + %22: %22 +fullOvation.getNumPeopleNeeded() + %22%5Cn%22);%0A%0A                caseNumber++;%0A                numPeople.clear();%0A            %7D%0A            //%7D%0A%0A            bw.close();%0A        %7D catch (FileNotFoundException e) %7B%0A            e.printStackTrace();%0A        %7D catch (IOException e) %7B%0A            e.printStackTrace();%0A        %7D%0A    %7D%0A%7D%0A

Add files via upload