This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, m;
cin >> n >> m;
vector<int> a(m), b(m), c(m);
for (int i = 0; i < m; i++) {
cin >> a[i] >> b[i] >> c[i];
if (a[i] > b[i]) {
swap(a[i], b[i]);
}
}
int ans = 1E9;
for (int mask = 0; mask < (1 << m); mask++) {
vector<int> h(n + 1);
for (int i = 0; i < m; i++) {
if (mask >> i & 1) {
h[0]++;
h[a[i]]--;
h[b[i]]++;
} else {
h[a[i]]++;
h[b[i]]--;
}
}
for (int i = 1; i <= n; i++) {
h[i] += h[i - 1];
}
ans = min(ans, *max_element(h.begin(), h.end()));
}
cout << ans << "\n";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |