//author:
#include <bits/stdc++.h>
using namespace std;
#define int long long
using i64 = long long;
const int MAXN = 2e6 + 5;
#define ONLINE_JUDGE
void solve() {
int n;
cin >> n;
vector <pair <int, int>> vec(n +5);
for(int i = 1; i <= n; i++) {
cin >> vec[i].first >> vec[i].second;
}
map <int, int> mp;
for(int i = 1; i <= n; i++)
mp[vec[i].first] = mp[vec[i].second] = 0;
int cnt = 1;
for(auto &[a, b] : mp)
b = cnt++;
for(int i = 1; i <= n; i++)
vec[i].first = mp[vec[i].first], vec[i].second = mp[vec[i].second];
int q;
cin >> q;
for(int i = 1; i <= q; i++) {
int l, r;
cin >> l >> r;
vector <int> pref(2 * MAXN);
for(int i = l; i <= r; i++) {
pref[vec[i].first]++;
pref[vec[i].second +1]--;
}
vector <int> arr = pref;
for(int i = 1; i <= cnt + 4; i++)
arr[i] += arr[i -1];
cout << *max_element(arr.begin(), arr.end()) << "\n";
}
return;
}
signed main() {
#ifndef ONLINE_JUDGE
freopen(".in", "r", stdin);
freopen(".out", "w", stdout);
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
int t = 1; //cin >> t;
while(t--)
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
490 ms |
89760 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1027 ms |
64000 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1027 ms |
64000 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1030 ms |
91384 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
490 ms |
89760 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |