답안 #901485

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
901485 2024-01-09T12:59:14 Z 406 Examination (JOI19_examination) C++17
100 / 100
1376 ms 7872 KB
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx2")
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)

using namespace std;
using ar = array<int, 2>;

const int N = 1e5 + 5;
const long long INF = 1ll << 60;
ar A[N];
int t[3][N], n, q;

signed main() {
        ios::sync_with_stdio(false);
        cin.tie(nullptr); 
        cin >> n >> q;
        FOR(i, 0, n)
                cin >> A[i][0] >> A[i][1];
        auto cmp = [&](const auto a, const auto b) {
                return a[0] + a[1] < b[0] + b[1];
        };
        sort(A, A + n, cmp);

        FOR(i, 0, n) {
                t[0][i] = A[i][0]; 
                t[1][i] = A[i][1]; 
                t[2][i] = A[i][0] + A[i][1];
        }

        while (q--) {
                int a, b, c;
                cin >> a >> b >> c;
                c = max(c, a + b);
                int it = lower_bound(t[2], t[2] + n, c) - t[2];
                int ans = 0;
                for (; it < n; ++it) 
                        ans += t[0][it] >= a && t[1][it] >= b;
                cout << ans << '\n';
        }
        return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 3 ms 604 KB Output is correct
8 Correct 4 ms 604 KB Output is correct
9 Correct 3 ms 604 KB Output is correct
10 Correct 3 ms 640 KB Output is correct
11 Correct 3 ms 480 KB Output is correct
12 Correct 3 ms 348 KB Output is correct
13 Correct 3 ms 604 KB Output is correct
14 Correct 3 ms 600 KB Output is correct
15 Correct 4 ms 816 KB Output is correct
16 Correct 3 ms 604 KB Output is correct
17 Correct 3 ms 488 KB Output is correct
18 Correct 2 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 732 ms 5472 KB Output is correct
2 Correct 720 ms 5212 KB Output is correct
3 Correct 685 ms 5296 KB Output is correct
4 Correct 705 ms 4480 KB Output is correct
5 Correct 691 ms 4936 KB Output is correct
6 Correct 736 ms 3772 KB Output is correct
7 Correct 1149 ms 5396 KB Output is correct
8 Correct 1151 ms 5896 KB Output is correct
9 Correct 1376 ms 5352 KB Output is correct
10 Correct 683 ms 4876 KB Output is correct
11 Correct 706 ms 4476 KB Output is correct
12 Correct 129 ms 3412 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 732 ms 5472 KB Output is correct
2 Correct 720 ms 5212 KB Output is correct
3 Correct 685 ms 5296 KB Output is correct
4 Correct 705 ms 4480 KB Output is correct
5 Correct 691 ms 4936 KB Output is correct
6 Correct 736 ms 3772 KB Output is correct
7 Correct 1149 ms 5396 KB Output is correct
8 Correct 1151 ms 5896 KB Output is correct
9 Correct 1376 ms 5352 KB Output is correct
10 Correct 683 ms 4876 KB Output is correct
11 Correct 706 ms 4476 KB Output is correct
12 Correct 129 ms 3412 KB Output is correct
13 Correct 454 ms 6064 KB Output is correct
14 Correct 700 ms 5956 KB Output is correct
15 Correct 732 ms 5392 KB Output is correct
16 Correct 468 ms 5064 KB Output is correct
17 Correct 477 ms 5024 KB Output is correct
18 Correct 667 ms 4248 KB Output is correct
19 Correct 480 ms 5720 KB Output is correct
20 Correct 577 ms 5716 KB Output is correct
21 Correct 735 ms 5760 KB Output is correct
22 Correct 702 ms 4724 KB Output is correct
23 Correct 707 ms 4704 KB Output is correct
24 Correct 147 ms 3412 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 3 ms 604 KB Output is correct
8 Correct 4 ms 604 KB Output is correct
9 Correct 3 ms 604 KB Output is correct
10 Correct 3 ms 640 KB Output is correct
11 Correct 3 ms 480 KB Output is correct
12 Correct 3 ms 348 KB Output is correct
13 Correct 3 ms 604 KB Output is correct
14 Correct 3 ms 600 KB Output is correct
15 Correct 4 ms 816 KB Output is correct
16 Correct 3 ms 604 KB Output is correct
17 Correct 3 ms 488 KB Output is correct
18 Correct 2 ms 348 KB Output is correct
19 Correct 732 ms 5472 KB Output is correct
20 Correct 720 ms 5212 KB Output is correct
21 Correct 685 ms 5296 KB Output is correct
22 Correct 705 ms 4480 KB Output is correct
23 Correct 691 ms 4936 KB Output is correct
24 Correct 736 ms 3772 KB Output is correct
25 Correct 1149 ms 5396 KB Output is correct
26 Correct 1151 ms 5896 KB Output is correct
27 Correct 1376 ms 5352 KB Output is correct
28 Correct 683 ms 4876 KB Output is correct
29 Correct 706 ms 4476 KB Output is correct
30 Correct 129 ms 3412 KB Output is correct
31 Correct 454 ms 6064 KB Output is correct
32 Correct 700 ms 5956 KB Output is correct
33 Correct 732 ms 5392 KB Output is correct
34 Correct 468 ms 5064 KB Output is correct
35 Correct 477 ms 5024 KB Output is correct
36 Correct 667 ms 4248 KB Output is correct
37 Correct 480 ms 5720 KB Output is correct
38 Correct 577 ms 5716 KB Output is correct
39 Correct 735 ms 5760 KB Output is correct
40 Correct 702 ms 4724 KB Output is correct
41 Correct 707 ms 4704 KB Output is correct
42 Correct 147 ms 3412 KB Output is correct
43 Correct 464 ms 7872 KB Output is correct
44 Correct 463 ms 7680 KB Output is correct
45 Correct 703 ms 7772 KB Output is correct
46 Correct 478 ms 6156 KB Output is correct
47 Correct 475 ms 6016 KB Output is correct
48 Correct 217 ms 3624 KB Output is correct
49 Correct 1056 ms 7760 KB Output is correct
50 Correct 658 ms 7872 KB Output is correct
51 Correct 1193 ms 7408 KB Output is correct
52 Correct 479 ms 6484 KB Output is correct
53 Correct 747 ms 5472 KB Output is correct