#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define st first
#define nd second
#define lb lower_bound
const int N = 100005;
int n, q, s, t, x, y, z;
multiset <pair<int, int> > sum;
multiset <pair<int, int> > inf;
multiset <pair<int, int> > mat;
vector <pair<int, int> > normal;
vector <pair<int, pair<int, int> > > sumv;
vector <pair<int, int> > infv;
vector <pair<int, int> > matv;
pair<int, int> arr[N];
int32_t main(){
cin >> n >> q;
for (int i = 0; i < n; i++){
cin >> s >> t;
arr[i] = {s,t};
sum.insert({s+t, i});
// sumv.pb({s+t, {s, t}});
// mat.insert({s, i});
// matv.pb({s,t});
// inf.insert({t, i});
// infv.pb({t,s});
}
// sort(sumv.begin(), sumv.end());
// sort(matv.begin(), matv.end());
// sort(infv.begin(), infv.end());
for (int i = 0; i < q; i++){
cin >> x >> y >> z;
for(auto k = sum.lb({z, 0}); k != sum.end(); k++){
mat.insert(arr[(*k).nd]);
}
for(auto k = mat.lb({x, 0}); k != mat.end(); k++){
inf.insert({(*k).nd, (*k).st});
// cout << arr[(*k).nd].nd << " ";
}
cout << distance(inf.lb({y, 0}), inf.end()) << endl;
mat.clear();
inf.clear();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
1 ms |
256 KB |
Output is correct |
5 |
Correct |
1 ms |
256 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1467 ms |
1256 KB |
Output is correct |
8 |
Correct |
1386 ms |
1288 KB |
Output is correct |
9 |
Correct |
1484 ms |
1144 KB |
Output is correct |
10 |
Correct |
1297 ms |
1144 KB |
Output is correct |
11 |
Correct |
1313 ms |
1144 KB |
Output is correct |
12 |
Correct |
1304 ms |
1016 KB |
Output is correct |
13 |
Correct |
2763 ms |
1116 KB |
Output is correct |
14 |
Correct |
2774 ms |
1156 KB |
Output is correct |
15 |
Correct |
2730 ms |
1272 KB |
Output is correct |
16 |
Correct |
2121 ms |
1072 KB |
Output is correct |
17 |
Correct |
1070 ms |
1072 KB |
Output is correct |
18 |
Correct |
434 ms |
1016 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3085 ms |
22036 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3085 ms |
22036 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
1 ms |
256 KB |
Output is correct |
5 |
Correct |
1 ms |
256 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1467 ms |
1256 KB |
Output is correct |
8 |
Correct |
1386 ms |
1288 KB |
Output is correct |
9 |
Correct |
1484 ms |
1144 KB |
Output is correct |
10 |
Correct |
1297 ms |
1144 KB |
Output is correct |
11 |
Correct |
1313 ms |
1144 KB |
Output is correct |
12 |
Correct |
1304 ms |
1016 KB |
Output is correct |
13 |
Correct |
2763 ms |
1116 KB |
Output is correct |
14 |
Correct |
2774 ms |
1156 KB |
Output is correct |
15 |
Correct |
2730 ms |
1272 KB |
Output is correct |
16 |
Correct |
2121 ms |
1072 KB |
Output is correct |
17 |
Correct |
1070 ms |
1072 KB |
Output is correct |
18 |
Correct |
434 ms |
1016 KB |
Output is correct |
19 |
Execution timed out |
3085 ms |
22036 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |