-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain2.java
More file actions
40 lines (36 loc) · 1.09 KB
/
Main2.java
File metadata and controls
40 lines (36 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package com.jd;
import java.io.BufferedInputStream;
import java.util.Scanner;
public class Main2 {
public static void main(String[] args) {
Scanner in = new Scanner(new BufferedInputStream(System.in));
int n = in.nextInt();
int m = in.nextInt();
int[][] array = new int[n + 1][n + 1];
for (int t = 0; t < m; t++) {
int i = in.nextInt();
int j = in.nextInt();
int val = in.nextInt();
array[i][j] = val;
array[j][i] = val;
}
int maxWeight = 0;
int result = 0;
for (int i = 1; i <= n; i++) {
int temp = 0;
int j = i;
int count = m - 1;
while (count > 0) {
count--;
temp = Integer.MAX_VALUE;
;
if (array[j%(n + 1)][(j + 1)%(n + 1)] < temp) {
temp = array[j%(n + 1)][(j + 1)%(n + 1)];
}
j++;
}
if (temp > result) result = temp;
}
System.out.println(result);
}
}