#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int N,M;
cin >> N >> M;
vector<pair<int,int>> requests(M);
for(auto&[a,b]:requests) {
int c;cin>>a>>b>>c;
if(b<a)swap(a,b);
}
auto check = [&](int mask) {
vector<int> curr(N+1);
for(int i=0;i<M;i++) {
if(mask&(1<<i)) {
for(int x=requests[i].first;x<requests[i].second;x++)curr[x]++;
} else {
for(int x=1;x<requests[i].first;x++)curr[x]++;
for(int x=requests[i].second;x<=N;x++)curr[x]++;
}
}
return *max_element(curr.begin(), curr.end());
};
long long ans = M;
for(int mask=0;mask<(1<<M);mask++)ans=min(ans,check(mask));
cout << ans << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
193 ms |
428 KB |
Output is correct |
2 |
Correct |
195 ms |
348 KB |
Output is correct |
3 |
Correct |
218 ms |
348 KB |
Output is correct |
4 |
Correct |
190 ms |
432 KB |
Output is correct |
5 |
Correct |
195 ms |
348 KB |
Output is correct |
6 |
Correct |
191 ms |
348 KB |
Output is correct |
7 |
Correct |
197 ms |
348 KB |
Output is correct |
8 |
Correct |
186 ms |
348 KB |
Output is correct |
9 |
Correct |
208 ms |
348 KB |
Output is correct |
10 |
Correct |
196 ms |
432 KB |
Output is correct |
11 |
Correct |
195 ms |
348 KB |
Output is correct |
12 |
Correct |
214 ms |
428 KB |
Output is correct |
13 |
Correct |
192 ms |
428 KB |
Output is correct |
14 |
Correct |
191 ms |
348 KB |
Output is correct |
15 |
Correct |
203 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
193 ms |
428 KB |
Output is correct |
2 |
Correct |
195 ms |
348 KB |
Output is correct |
3 |
Correct |
218 ms |
348 KB |
Output is correct |
4 |
Correct |
190 ms |
432 KB |
Output is correct |
5 |
Correct |
195 ms |
348 KB |
Output is correct |
6 |
Correct |
191 ms |
348 KB |
Output is correct |
7 |
Correct |
197 ms |
348 KB |
Output is correct |
8 |
Correct |
186 ms |
348 KB |
Output is correct |
9 |
Correct |
208 ms |
348 KB |
Output is correct |
10 |
Correct |
196 ms |
432 KB |
Output is correct |
11 |
Correct |
195 ms |
348 KB |
Output is correct |
12 |
Correct |
214 ms |
428 KB |
Output is correct |
13 |
Correct |
192 ms |
428 KB |
Output is correct |
14 |
Correct |
191 ms |
348 KB |
Output is correct |
15 |
Correct |
203 ms |
348 KB |
Output is correct |
16 |
Incorrect |
94 ms |
348 KB |
Output isn't correct |
17 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
193 ms |
428 KB |
Output is correct |
2 |
Correct |
195 ms |
348 KB |
Output is correct |
3 |
Correct |
218 ms |
348 KB |
Output is correct |
4 |
Correct |
190 ms |
432 KB |
Output is correct |
5 |
Correct |
195 ms |
348 KB |
Output is correct |
6 |
Correct |
191 ms |
348 KB |
Output is correct |
7 |
Correct |
197 ms |
348 KB |
Output is correct |
8 |
Correct |
186 ms |
348 KB |
Output is correct |
9 |
Correct |
208 ms |
348 KB |
Output is correct |
10 |
Correct |
196 ms |
432 KB |
Output is correct |
11 |
Correct |
195 ms |
348 KB |
Output is correct |
12 |
Correct |
214 ms |
428 KB |
Output is correct |
13 |
Correct |
192 ms |
428 KB |
Output is correct |
14 |
Correct |
191 ms |
348 KB |
Output is correct |
15 |
Correct |
203 ms |
348 KB |
Output is correct |
16 |
Incorrect |
94 ms |
348 KB |
Output isn't correct |
17 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
193 ms |
428 KB |
Output is correct |
2 |
Correct |
195 ms |
348 KB |
Output is correct |
3 |
Correct |
218 ms |
348 KB |
Output is correct |
4 |
Correct |
190 ms |
432 KB |
Output is correct |
5 |
Correct |
195 ms |
348 KB |
Output is correct |
6 |
Correct |
191 ms |
348 KB |
Output is correct |
7 |
Correct |
197 ms |
348 KB |
Output is correct |
8 |
Correct |
186 ms |
348 KB |
Output is correct |
9 |
Correct |
208 ms |
348 KB |
Output is correct |
10 |
Correct |
196 ms |
432 KB |
Output is correct |
11 |
Correct |
195 ms |
348 KB |
Output is correct |
12 |
Correct |
214 ms |
428 KB |
Output is correct |
13 |
Correct |
192 ms |
428 KB |
Output is correct |
14 |
Correct |
191 ms |
348 KB |
Output is correct |
15 |
Correct |
203 ms |
348 KB |
Output is correct |
16 |
Incorrect |
94 ms |
348 KB |
Output isn't correct |
17 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
193 ms |
428 KB |
Output is correct |
2 |
Correct |
195 ms |
348 KB |
Output is correct |
3 |
Correct |
218 ms |
348 KB |
Output is correct |
4 |
Correct |
190 ms |
432 KB |
Output is correct |
5 |
Correct |
195 ms |
348 KB |
Output is correct |
6 |
Correct |
191 ms |
348 KB |
Output is correct |
7 |
Correct |
197 ms |
348 KB |
Output is correct |
8 |
Correct |
186 ms |
348 KB |
Output is correct |
9 |
Correct |
208 ms |
348 KB |
Output is correct |
10 |
Correct |
196 ms |
432 KB |
Output is correct |
11 |
Correct |
195 ms |
348 KB |
Output is correct |
12 |
Correct |
214 ms |
428 KB |
Output is correct |
13 |
Correct |
192 ms |
428 KB |
Output is correct |
14 |
Correct |
191 ms |
348 KB |
Output is correct |
15 |
Correct |
203 ms |
348 KB |
Output is correct |
16 |
Incorrect |
94 ms |
348 KB |
Output isn't correct |
17 |
Halted |
0 ms |
0 KB |
- |