fork download
  1. #include <stdio.h>
  2.  
  3. #define MAXN 101
  4.  
  5. int main() {
  6. int musicos[MAXN][MAXN], n, m, x, y, z;
  7. int aux = -1, sol[3];
  8. int i, j, k;
  9.  
  10. scanf("%d %d", &n, &m);
  11.  
  12. for (i = 0; i < m; i++) {
  13. scanf("%d %d %d", &x, &y, &z);
  14. x--;
  15. y--;
  16. musicos[x][y] = z;
  17. musicos[y][x] = z;
  18. }
  19.  
  20. for (i = 0; i < n; i++) {
  21. for (j = i+1; j < n; j++) {
  22. for (k = j+1; k < n; k++) {
  23. if (musicos[i][j] + musicos[i][k] + musicos[j][k] > aux) {
  24. aux = musicos[i][j] + musicos[i][k] + musicos[j][k];
  25. sol[0] = i;
  26. sol[1] = j;
  27. sol[2] = k;
  28. }
  29. }
  30. }
  31. }
  32.  
  33. printf("%d %d %d\n", sol[0]+1, sol[1]+1, sol[2]+1);
  34.  
  35. return 0;
  36. }
Success #stdin #stdout 0s 2172KB
stdin
5 8
1 2 50
1 3 50
1 4 50
2 3 50
2 5 10
3 4 50
3 5 25
4 5 20
stdout
1 2 3