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 <stdio.h>
#include <string.h>
#define N 100000
#define M 200000
#define INF 0x3f3f3f3f
int min(int a, int b) { return a < b ? a : b; }
int max(int a, int b) { return a > b ? a : b; }
int main() {
static int xx[N], yy[N], cc[N], dd[M];
int n, m, i, b, a, tmp, ans, x;
scanf("%d%d", &m, &n);
for (i = 0; i < n; i++) {
scanf("%d%d%d", &xx[i], &yy[i], &cc[i]), xx[i]--, yy[i]--;
if (xx[i] > yy[i])
tmp = xx[i], xx[i] = yy[i], yy[i] = tmp;
}
ans = INF;
for (b = 0; b < 1 << n; b++) {
memset(dd, 0, m * sizeof *dd);
for (i = 0; i < n; i++)
if ((b & 1 << i) == 0)
dd[xx[i]]++, dd[yy[i]]--;
else
dd[0]++, dd[xx[i]]--, dd[yy[i]]++;
for (a = 1; a < m; a++)
dd[a] += dd[a - 1];
x = 0;
for (a = 0; a < m; a++)
x = max(x, dd[a]);
ans = min(ans, x);
}
printf("%d\n", ans);
return 0;
}
Compilation message (stderr)
arranging_tickets.c: In function 'main':
arranging_tickets.c:15:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
15 | scanf("%d%d", &m, &n);
| ^~~~~~~~~~~~~~~~~~~~~
arranging_tickets.c:17:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
17 | scanf("%d%d%d", &xx[i], &yy[i], &cc[i]), xx[i]--, yy[i]--;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | 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... |