# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
548969 | LucaDantas | Arranging Tickets (JOI17_arranging_tickets) | C++17 | 137 ms | 340 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;
constexpr int maxn = 22;
struct Itv {
int l, r, qtd; // subtasks 1-4 qtd == 1 so I can ignore it for what I'm going to code
} itv[maxn];
int a[maxn]; // quantos caras precisam passar por cada pos
int check(int mask, int n) {
memset(a, 0, sizeof a);
for(int i = 0; i < n; i++) {
if(mask & (1 << i))
a[itv[i].l]++, a[itv[i].r]--;
else
a[itv[i].r]++, a[1]++, a[itv[i].l]--;
}
int ans = 0;
for(int i = 1; i < maxn; i++)
a[i] += a[i-1], ans = max(ans, a[i]);
return ans;
}
int main() {
int sz, n; scanf("%d %d", &sz, &n);
for(int i = 0; i < n; i++) {
scanf("%d %d %d", &itv[i].l, &itv[i].r, &itv[i].qtd);
if(itv[i].l > itv[i].r) swap(itv[i].l, itv[i].r);
}
int ans = n;
for(int mask = 0; mask < (1 << n); mask++)
ans = min(ans, check(mask, n));
printf("%d\n", ans);
}
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... |