# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
408255 | Mamnoon_Siam | Arranging Tickets (JOI17_arranging_tickets) | C++17 | 1287 ms | 296 KiB |
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;
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
#define all(v) begin(v), end(v)
#define sz(v) (int)(v).size()
#define fi first
#define se second
int main(int argc, char const *argv[])
{
#ifdef LOCAL
freopen("in", "r", stdin);
#endif
int n, m;
scanf("%d %d", &n, &m);
vi a(m), b(m), c(m);
for(int i = 0; i < m; ++i) {
scanf("%d %d %d", &a[i], &b[i], &c[i]);
a[i]--, b[i]--;
}
ll ans = LLONG_MAX;
for(int msk = 0; msk < (1 << m); ++msk) {
vector<ll> cnt(n);
for(int i = 0; i < m; ++i) {
int from = a[i], to = b[i];
if(msk >> i & 1) swap(from, to);
for(int j = from; j != to; j = (j+1)%n) {
cnt[j] += c[i];
}
}
ans = min(ans, *max_element(all(cnt)));
}
printf("%lld\n", ans);
return 0;
}
/*
* use std::array instead of std::vector, if u can
* overflow?
* array bounds
*/
Compilation message (stderr)
# | 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... |