# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
757500 | 2023-06-13T09:09:41 Z | vjudge1 | Lightning Conductor (POI11_pio) | Java 11 | 0 ms | 0 KB |
import java.util.*; public class Main { public static void main(String args[]) { Scanner s = new Scanner(System.in); int n = s.nextInt(); ArrayList<Integer> arr = new ArrayList<Integer>(); for (int i=0; i<n; i++){ arr.add(s.nextInt()); } for (int i=0; i<n; i++){ System.out.println(operate(n, i, arr)); } } public static int operate(int n, int ind, ArrayList<Integer> arr){ int min = 0; int hi = arr.get(ind); for (int i=0; i<n; i++){ if (n == ind){ continue; } int a = (int) Math.ceil(Math.sqrt(Math.abs(ind-i))) + arr.get(i) - hi; if (a>min){ min = a; } } return min; } }