import java.util.*;
class sol{
public static void main(String args[]){
Scanner scanner=new Scanner(System.in);
int c=scanner.nextInt();
int f=scanner.nextInt();
int[] x=new int[f];
int[] y=new int[f];
int[] p=new int[f];
//int p=1;
int sum=0;
for(int i=0;i<f;i++){
x[i]=scanner.nextInt();
y[i]=scanner.nextInt();
p[i]=scanner.nextInt();
}
Arrays.sort§;
f=c-1;
for(int j=0;j<f;j++){
sum=sum+p[j];
}
System.out.println(sum);
}
}
Question link. And also provide your approach. What you are doing.