Submission #959509

#TimeUsernameProblemLanguageResultExecution timeMemory
959509edogawa_somethingArranging Tickets (JOI17_arranging_tickets)C++17
10 / 100
139 ms604 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<ll> vii; typedef pair<ll,ll> pii; #define F first #define S second #define pb push_back #define all(v) v.begin(),v.end() const ll M=310; const ll inf=2e18; ll n,m,a[M],b[M],c[M]; bool rev[M]; ll calc(){ for(int i=0;i<n+1;i++) c[i]=0; for(int i=0;i<m;i++){ if(rev[i]){ c[1]++; c[a[i]]--; c[b[i]]++,c[n+1]--; } else{ c[a[i]]++; c[b[i]]--; } } ll cur=0,res=0; for(int i=1;i<=n;i++){ cur+=c[i]; res=max(res,cur); } return res; } int main(){ ios_base::sync_with_stdio(0),cin.tie(0); cin>>n>>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]); } ll ans=inf; for(int i=0;i<(1<<m);i++){ for(int bit=0;bit<m;bit++){ rev[bit]=((i&(1<<bit))>0); } ans=min(ans,calc()); } 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...