Submission #1176097

#TimeUsernameProblemLanguageResultExecution timeMemory
1176097vibhasIntercastellar (JOI22_ho_t1)Java
100 / 100
532 ms61288 KiB
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; public class Main { public static void main(String[] args) throws Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); List<NewInteger> list = new ArrayList<>(); // this list contains what number comes how many times. for(int i = 0; i < n; i++){ int currentValue = Integer.parseInt(br.readLine()); int modified = currentValue; while(modified % 2 == 0){ // while it can still be divided modified /= 2; } list.add(new NewInteger(modified, currentValue/modified)); } int q = Integer.parseInt(br.readLine()); // queries. long currBound = list.get(0).occ; // our upper index bound long currVal = list.get(0).val; // the actual value for that index int currIndex = 1; // current index for(; q > 0; q--){ // iterate through the queries (sorted in ascending) long num = Long.parseLong(br.readLine()); while(num > currBound){ currBound += list.get(currIndex).occ; // upping it more currVal = list.get(currIndex).val; // changing the value currIndex ++; // and the index } System.out.println(currVal); } } } class NewInteger{ // class that can contain the number of occurrences and values for each new number. int occ; int val; public NewInteger(int value, int numOcc){ this.occ = numOcc; this.val = value; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...