답안 #715193

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
715193 2023-03-26T07:42:42 Z murad_2005 Examination (JOI19_examination) C++14
22 / 100
416 ms 22600 KB
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define piii pair<int, pii>
#define pllll pair<ll, ll>
#define plli pair<ll, int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define size(v) v.size()
#define INF 1e9
#define f first
#define s second
#define ln "\n"

using namespace std;

vector<pii>p;

void Sub1(int n, int q){
    p.resize(n + 1);
    for(int i = 1; i <= n; ++i){
        cin >> p[i].f >> p[i].s;
    }
    while(q--){
        int x, y, z;
        cin >> x >> y >> z;
        int cnt = 0;
        for(int i = 1; i <= n; i++){
            if(p[i].f >= x && p[i].s >= y && p[i].f + p[i].s >= z){
                cnt++;
            }
        }
        cout << cnt << "\n";
    }
}

const int up = 1e5 + 5;

vector<int>st[up << 2];

void build(int v, int l, int r){
    if(l == r){
        st[v].pb(p[l - 1].s);
    }else{
        int mid = (l + r) >> 1;
        build(v << 1, l, mid);
        build((v << 1) | 1, mid + 1, r);
        st[v].resize(r - l + 1);
        merge(all(st[v << 1]), all(st[(v << 1) | 1]), st[v].begin());
    }
}

int query(int v, int l, int r, int ql, int qr, int val){
    if(r < ql || qr < l) return 0;
    else if(ql <= l && r <= qr){
        int pos = lower_bound(all(st[v]), val) - st[v].begin();
        return size(st[v]) - pos;
    }else{
        int mid = (l + r) >> 1;
        return query(v << 1, l, mid, ql, qr, val) + query((v << 1) | 1, mid + 1, r, ql, qr, val);
    }
}

void Sub2(int n, int q){
    p.resize(n);
    for(int i = 0; i < n; ++i){
        cin >> p[i].f >> p[i].s;
    }
    sort(all(p));
    build(1, 1, n);
    while(q--){
        int x, y, z;
        cin >> x >> y >> z;
        pii P = {x, 0};
        int pos = lower_bound(all(p), P) - p.begin();
        if(pos < n){
            cout << query(1, 1, n, pos + 1, n, y) << "\n";
        }else{
            cout << "0\n";
        }
    }
}

void solve(){
    int n, q;
    cin >> n >> q;
    if(n <= 3000 && q <= 3000){
        Sub1(n, q);
    }else{
        Sub2(n, q);
    }
}

int main(){
    int t;
    t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 9684 KB Output is correct
2 Correct 5 ms 9684 KB Output is correct
3 Correct 6 ms 9684 KB Output is correct
4 Correct 5 ms 9684 KB Output is correct
5 Correct 5 ms 9684 KB Output is correct
6 Correct 5 ms 9684 KB Output is correct
7 Correct 53 ms 9684 KB Output is correct
8 Correct 52 ms 9684 KB Output is correct
9 Correct 51 ms 9684 KB Output is correct
10 Correct 51 ms 9720 KB Output is correct
11 Correct 51 ms 9684 KB Output is correct
12 Correct 49 ms 9684 KB Output is correct
13 Correct 50 ms 9684 KB Output is correct
14 Correct 52 ms 9724 KB Output is correct
15 Correct 52 ms 9724 KB Output is correct
16 Correct 29 ms 9684 KB Output is correct
17 Correct 39 ms 9724 KB Output is correct
18 Correct 18 ms 9684 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 399 ms 22600 KB Output is correct
2 Correct 413 ms 22444 KB Output is correct
3 Correct 402 ms 22504 KB Output is correct
4 Correct 366 ms 22488 KB Output is correct
5 Correct 314 ms 22476 KB Output is correct
6 Correct 264 ms 22520 KB Output is correct
7 Correct 388 ms 22436 KB Output is correct
8 Correct 398 ms 22536 KB Output is correct
9 Correct 364 ms 22556 KB Output is correct
10 Correct 256 ms 22424 KB Output is correct
11 Correct 333 ms 22356 KB Output is correct
12 Correct 222 ms 22112 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 399 ms 22600 KB Output is correct
2 Correct 413 ms 22444 KB Output is correct
3 Correct 402 ms 22504 KB Output is correct
4 Correct 366 ms 22488 KB Output is correct
5 Correct 314 ms 22476 KB Output is correct
6 Correct 264 ms 22520 KB Output is correct
7 Correct 388 ms 22436 KB Output is correct
8 Correct 398 ms 22536 KB Output is correct
9 Correct 364 ms 22556 KB Output is correct
10 Correct 256 ms 22424 KB Output is correct
11 Correct 333 ms 22356 KB Output is correct
12 Correct 222 ms 22112 KB Output is correct
13 Incorrect 416 ms 22508 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 9684 KB Output is correct
2 Correct 5 ms 9684 KB Output is correct
3 Correct 6 ms 9684 KB Output is correct
4 Correct 5 ms 9684 KB Output is correct
5 Correct 5 ms 9684 KB Output is correct
6 Correct 5 ms 9684 KB Output is correct
7 Correct 53 ms 9684 KB Output is correct
8 Correct 52 ms 9684 KB Output is correct
9 Correct 51 ms 9684 KB Output is correct
10 Correct 51 ms 9720 KB Output is correct
11 Correct 51 ms 9684 KB Output is correct
12 Correct 49 ms 9684 KB Output is correct
13 Correct 50 ms 9684 KB Output is correct
14 Correct 52 ms 9724 KB Output is correct
15 Correct 52 ms 9724 KB Output is correct
16 Correct 29 ms 9684 KB Output is correct
17 Correct 39 ms 9724 KB Output is correct
18 Correct 18 ms 9684 KB Output is correct
19 Correct 399 ms 22600 KB Output is correct
20 Correct 413 ms 22444 KB Output is correct
21 Correct 402 ms 22504 KB Output is correct
22 Correct 366 ms 22488 KB Output is correct
23 Correct 314 ms 22476 KB Output is correct
24 Correct 264 ms 22520 KB Output is correct
25 Correct 388 ms 22436 KB Output is correct
26 Correct 398 ms 22536 KB Output is correct
27 Correct 364 ms 22556 KB Output is correct
28 Correct 256 ms 22424 KB Output is correct
29 Correct 333 ms 22356 KB Output is correct
30 Correct 222 ms 22112 KB Output is correct
31 Incorrect 416 ms 22508 KB Output isn't correct
32 Halted 0 ms 0 KB -