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;
#define ar array
#define int long long
signed main(){
ios::sync_with_stdio(0); cin.tie(0);
int n, m; cin>>n>>m;
vector<int> l(m), r(m), c(m);
for(int i=0;i<m;i++){
cin>>l[i]>>r[i]>>c[i];
if(l[i] > r[i]) swap(l[i], r[i]);
r[i]--;
}
int pref[25] {}, res = m;
for(int mask=0;mask < (1 << m);mask++){
memset(pref, 0, sizeof pref);
for(int i=0;i<m;i++){
if(mask >> i & 1) pref[l[i]]++, pref[r[i] + 1]--;
else {
pref[0]++, pref[l[i]]--, pref[r[i] + 1]++;
}
}
for(int i=1;i<=n;i++){
pref[i] += pref[i-1];
}
res = min(res, *max_element(pref, pref + 24));
}
cout<<res<<"\n";
}
# | 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... |