# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
134952 | mirbek01 | Port Facility (JOI17_port_facility) | C++11 | 2 ms | 376 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;
const int N = 1e6 + 2;
struct st{
int a, b;
}
ar[N];
int n, fen[N + N];
void upd(int pos){
for(int i = pos; i < N + N; i |= i + 1)
fen[i] ++;
}
int get(int r){
int ret = 0;
for(int i = r; i > 0; i = (i & (i + 1)) - 1)
ret += fen[i];
return ret;
}
int get(int l, int r){
return get(r) - get(l - 1);
}
int main(){
cin >> n;
for(int i = 1; i <= n; i ++)
scanf("%d %d", &ar[i].a, &ar[i].b);
sort(ar + 1, ar + n + 1, [&](st a, st b){
return a.a < b.a;});
for(int i = 1; i <= n; i ++){
int cnt = get(ar[i].a, ar[i].b);
if(cnt > 1){
cout << 0 << endl;
return 0;
}
upd(ar[i].b);
}
}
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... |