#include <bits/stdc++.h>
using ll = long long;
using ull = unsigned long long;
using pair = std::array<int, 2>;
using pairll = std::array<ll, 2>;
using tri = std::array<int, 3>;
using trill = std::array<ll, 3>;
constexpr long long MOD = 998244353;
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int N, Q;
std::cin >> N >> Q;
std::vector<trill> v(N);
for (int i = 0; i < N; i++) {
ll a, b;
std::cin >> a >> b;
trill score = {a, b, a + b};
v[i] = score;
}
while (Q--) {
std::sort(v.begin(), v.end(), [&](trill a, trill b) {return a[0] < b[0];});
ll s, t, u;
std::cin >> s >> t >> u;
trill check = {s, 0, 0};
auto ait = std::upper_bound(v.begin(), v.end(), check, [&](trill value, trill element){return element[0] >= value[0];});
if (ait == v.end()) {
std::cout << "0\n";
continue;
}
std::sort(v.begin() + (ait - v.begin()), v.end(), [&](trill a, trill b) {return a[1] < b[1];});
check = {0, t, 0};
auto bit = std::upper_bound(v.begin() + (ait - v.begin()), v.end(), check, [&](trill value, trill element){return element[1] >= value[1];});
if (bit == v.end()) {
std::cout << "0\n";
continue;
}
std::sort(v.begin() + (bit - v.begin()), v.end(), [&](trill a, trill b) {return a[2] < b[2];});
check = {0, 0, u};
auto toit = std::upper_bound(v.begin() + (bit - v.begin()), v.end(), check, [&](trill value, trill element) {return element[2] >= value[2];});
std::cout << (v.end() - toit) << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
550 ms |
668 KB |
Output is correct |
8 |
Correct |
534 ms |
604 KB |
Output is correct |
9 |
Correct |
550 ms |
664 KB |
Output is correct |
10 |
Correct |
412 ms |
604 KB |
Output is correct |
11 |
Correct |
399 ms |
616 KB |
Output is correct |
12 |
Correct |
301 ms |
344 KB |
Output is correct |
13 |
Correct |
543 ms |
840 KB |
Output is correct |
14 |
Correct |
547 ms |
852 KB |
Output is correct |
15 |
Correct |
538 ms |
600 KB |
Output is correct |
16 |
Correct |
225 ms |
344 KB |
Output is correct |
17 |
Correct |
216 ms |
604 KB |
Output is correct |
18 |
Correct |
127 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3010 ms |
2648 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3010 ms |
2648 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
550 ms |
668 KB |
Output is correct |
8 |
Correct |
534 ms |
604 KB |
Output is correct |
9 |
Correct |
550 ms |
664 KB |
Output is correct |
10 |
Correct |
412 ms |
604 KB |
Output is correct |
11 |
Correct |
399 ms |
616 KB |
Output is correct |
12 |
Correct |
301 ms |
344 KB |
Output is correct |
13 |
Correct |
543 ms |
840 KB |
Output is correct |
14 |
Correct |
547 ms |
852 KB |
Output is correct |
15 |
Correct |
538 ms |
600 KB |
Output is correct |
16 |
Correct |
225 ms |
344 KB |
Output is correct |
17 |
Correct |
216 ms |
604 KB |
Output is correct |
18 |
Correct |
127 ms |
344 KB |
Output is correct |
19 |
Execution timed out |
3010 ms |
2648 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |