Submission #21338

#TimeUsernameProblemLanguageResultExecution timeMemory
21338UshioArranging Tickets (JOI17_arranging_tickets)C++14
10 / 100
206 ms2180 KiB
#include <bits/stdc++.h> #define SZ(x) ((int) (x).size()) using namespace std; typedef long long i64; const int INF = 0x3f3f3f3f; const int NMAX = 6007; int main() { #ifdef LOCAL_RUN freopen("task.in", "r", stdin); freopen("task.out", "w", stdout); //freopen("task.err", "w", stderr); #endif // ONLINE_JUDGE ios::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; vector<int> left(m), right(m); for (int i = 0; i < m; ++i) { int x; cin >> left[i] >> right[i] >> x; if (left[i] > right[i]) { swap(left[i], right[i]); } left[i]--; right[i]--; } int ans = INF; for (int conf = 0; conf < (1 << m); ++conf) { vector<int> cnt(n, 0); for (int i = 0; i < m; ++i) { if (conf & (1 << i)) { cnt[0]++; cnt[left[i]]--; cnt[right[i]]++; } else { cnt[left[i]]++; cnt[right[i]]--; } } for (int i = 1; i < n; ++i) { cnt[i] += cnt[i - 1]; } ans = min(ans, *max_element(cnt.begin(), cnt.end())); } cout << ans << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...