제출 #126544

#제출 시각아이디문제언어결과실행 시간메모리
126544baluteshihArranging Tickets (JOI17_arranging_tickets)C++14
10 / 100
178 ms508 KiB
#include <bits/stdc++.h> #define jizz ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); #define pb push_back #define MP make_pair #define F first #define S second #define MEM(i,j) memset(i,j,sizeof i) #define ALL(v) v.begin(),v.end() #define ET cout << "\n" #define DB(a,s,e) {for(int i=s;i<e;++i) cout << a[i] << " ";ET;} using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; struct mode { int a,b,w; }arr[100005]; int sum[200005]; const int INF=1e9; int main() {jizz int n,m,ans=INF; cin >> n >> m; for(int i=0;i<m;++i) { cin >> arr[i].a >> arr[i].b >> arr[i].w; if(arr[i].a>arr[i].b) swap(arr[i].a,arr[i].b); } for(int i=(1<<m)-1;i>=0;--i) { for(int j=1;j<=n;++j) sum[j]=0; for(int j=0;j<m;++j) if(i>>j&1) sum[arr[j].a]+=arr[j].w,sum[arr[j].b]-=arr[j].w; else sum[1]+=arr[j].w,sum[arr[j].a]-=arr[j].w,sum[arr[j].b]+=arr[j].w; for(int j=1;j<=n;++j) sum[j]+=sum[j-1]; ans=min(ans,*max_element(sum+1,sum+n+1)); } 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...