#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007
#define INF 1000000019
#define POT (1<<21)
#define INFL 4000000000000000099LL
ll n,m,a,b,c;
vector<pair<ll,ll>>v;
ll ile[21];
int main()
{
cin>>n>>m;
for(ll i=0;i<m;i++){
cin>>a>>b>>c;
v.pb({a%n,b%n});
}
ll bst=INFL;
for(ll i=0;i<(1<<m);i++){
for(ll j=0;j<n;j++)ile[j]=0;
for(ll j=0;j<m;j++){
if((1<<j)&i){
for(ll k=v[j].ff;k!=v[j].ss;k=(k+1)%n)ile[k]++;
}
else{
for(ll k=v[j].ss;k!=v[j].ff;k=(k+1)%n)ile[k]++;
}
ll x=0;
for(ll j=0;j<n;j++){//cout<<ile[j]<<" ";
x=max(x,ile[j]);}
//cout<<"\n";
}
ll x=0;
for(ll j=0;j<n;j++){//cout<<ile[j]<<" ";
x=max(x,ile[j]);}
// cout<<"\n\n";
bst=min(bst,x);
}
cout<<bst;
}
# | 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... |