# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
565061 | dantoh000 | Arranging Tickets (JOI17_arranging_tickets) | C++14 | 231 ms | 332 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;
int n,m;
int a[25], b[25], c[25];
int x[25];
int main(){
scanf("%d%d",&n,&m);
for (int i = 0; i < m; i++){
scanf("%d%d%d",&a[i],&b[i],&c[i]);
if (a[i] > b[i]) swap(a[i],b[i]);
}
int ans = m;
for (int mask = 0; mask < (1<<m); mask++){
for (int i = 1; i <= n; i++){
x[i] = 0;
}
int ct = 0;
for (int i = 0; i < m; i++){
if ((mask>>i)&1){
for (int j = a[i]; j < b[i]; j++){
x[j]++;
}
}
else{
ct++;
for (int j = a[i]; j < b[i]; j++){
x[j]--;
}
}
}
int mx = 0;
for (int i = 1; i <= n; i++){
mx = max(mx, x[i]);
}
ans = min(ans,mx+ct);
}
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... |