Submission #55004

#TimeUsernameProblemLanguageResultExecution timeMemory
55004ksun48Arranging Tickets (JOI17_arranging_tickets)C++14
10 / 100
4034 ms936 KiB
#include <bits/stdc++.h> using namespace std; typedef long long LL; int main(){ cin.sync_with_stdio(0); cin.tie(0); LL n, m; cin >> n >> m; // stations 1 to n vector<vector<LL> > z; for(int i = 0; i < m; i++){ LL a, b, c; cin >> a >> b >> c; a--; b--; for(int j = 0; j < c; j++){ z.push_back(vector<LL>({a,b})); } } LL best = z.size(); for(LL r = 0; r < (1 << z.size()); r++){ vector<LL> freq(n,0); for(int j = 0; j < z.size(); j++){ LL c = z[j][0]; LL d = z[j][1]; if(r & (1 << j)){ swap(c,d); } while(c != d){ freq[c]++; c++; c %= n; } } LL maxused = 0; for(int j = 0; j < n; j++){ maxused = max(maxused, freq[j]); } best = min(best, maxused); } cout << best << '\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...