(int i, int j)
| 117 | } |
| 118 | |
| 119 | public static void update(int i, int j) { |
| 120 | if (j == 0) { |
| 121 | return; |
| 122 | } |
| 123 | int dist = Math.abs(arr[i] - arr[j]); |
| 124 | if (to1[i] == 0 || dist < dist1[i] || (dist == dist1[i] && arr[j] < arr[to1[i]])) { |
| 125 | to2[i] = to1[i]; |
| 126 | dist2[i] = dist1[i]; |
| 127 | to1[i] = j; |
| 128 | dist1[i] = dist; |
| 129 | } else if (to2[i] == 0 || dist < dist2[i] || (dist == dist2[i] && arr[j] < arr[to2[i]])) { |
| 130 | to2[i] = j; |
| 131 | dist2[i] = dist; |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | public static void delete(int i) { |
| 136 | int l = last[i]; |