Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <vector>
- typedef struct v
- {
- int begin;
- int end;
- int weight;
- };
- int main()
- {
- std::ifstream fin;
- std::ofstream fout;
- fin.open("input.txt", std::ios::in);
- fout.open("output.txt", std::ios::out);
- int n, m;
- fin >> n >> m;
- std::vector<v> arr(m);
- for (int i = 0; i < m; ++i)
- {
- fin >> arr[i].begin >> arr[i].end >> arr[i].weight;
- }
- for (int i = 0; i < m - 1; ++i)
- for (int j = i + 1; j < m; ++j)
- if (arr[i].begin == arr[j].begin && arr[i].end == arr[j].end ||
- arr[i].begin == arr[j].end && arr[i].end == arr[j].end)
- {
- int max_weight = std::max(arr[i].weight, arr[j].weight);
- arr[i].weight = max_weight;
- arr[j].weight = max_weight;
- }
- int max = 0;
- for (int i = 0; i < m; ++i)
- if (arr[i].weight > max)
- max = arr[i].weight;
- fout << max;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement