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