Submission #124625

# Submission time Handle Problem Language Result Execution time Memory
124625 2019-07-03T15:34:32 Z mirbek01 Examination (JOI19_examination) C++11
100 / 100
309 ms 10184 KB
# include <bits/stdc++.h>
 
using namespace std;
 
const int N = 2e5 + 3;
 
struct st{
    int x, y, z;
    int a, b, c;
}a[N], b[N];
 
int n, m, ans[N], fen[3][N];
vector <int> v1, v2, v3;
 
void upd(int tp, int r){
    for(; r < N; r |= r + 1)
        fen[tp][r] ++;
}
int get(int tp, int l){
    int ret = 0;
    for(; l > 0; l = (l & (l + 1)) - 1)
        ret += fen[tp][l];
    return ret;
}
 
int main(){
    scanf("%d %d", &n, &m);
 
    for(int i = 1; i <= n; i ++){
        scanf("%d %d", &a[i].a, &a[i].b);
        a[i].c = a[i].a + a[i].b;
        v1.push_back(a[i].a);
        v2.push_back(a[i].b);
        v3.push_back(a[i].c);
        a[i].x = i;
    }
 
    for(int i = 1; i <= m; i ++){
        scanf("%d %d %d", &b[i].x, &b[i].y, &b[i].z);
        b[i].z = max(b[i].z, b[i].x + b[i].y);
        v1.push_back(b[i].x);
        v2.push_back(b[i].y);
        v3.push_back(b[i].z);
    }
 
    sort(v1.begin(), v1.end());
    v1.resize(unique(v1.begin(), v1.end()) - v1.begin());
    sort(v2.begin(), v2.end());
    v2.resize(unique(v2.begin(), v2.end()) - v2.begin());
    sort(v3.begin(), v3.end());
    v3.resize(unique(v3.begin(), v3.end()) - v3.begin());
 
    for(int i = 1; i <= n; i ++){
        a[i].a = lower_bound(v1.begin(), v1.end(), a[i].a) - v1.begin() + 1;
        a[i].b = lower_bound(v2.begin(), v2.end(), a[i].b) - v2.begin() + 1;
        a[i].c = lower_bound(v3.begin(), v3.end(), a[i].c) - v3.begin() + 1;
    }
    for(int i = 1; i <= m; i ++){
        b[i].x = lower_bound(v1.begin(), v1.end(), b[i].x) - v1.begin() + 1;
        b[i].y = lower_bound(v2.begin(), v2.end(), b[i].y) - v2.begin() + 1;
        b[i].z = lower_bound(v3.begin(), v3.end(), b[i].z) - v3.begin() + 1;
        b[i].a = i;
    }
 
    sort(a + 1, a + n + 1, [](st a, st b){
                            return a.c > b.c;});
    sort(b + 1, b + m + 1, [](st a, st b){
                            return a.z > b.z;});
 
    int pt = 0;
 
    for(int i = 1; i <= m; i ++){
        while(pt + 1 <= n && a[pt + 1].c >= b[i].z){
            pt ++;
            upd(1, a[pt].a);
            upd(2, a[pt].b);
        }
        ans[ b[i].a ] = pt - get(1, b[i].x - 1) - get(2, b[i].y - 1);
    }
 
    for(int i = 1; i <= m; i ++)
        printf("%d\n", ans[i]);
}

Compilation message

examination.cpp: In function 'int main()':
examination.cpp:27:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &m);
     ~~~~~^~~~~~~~~~~~~~~~~
examination.cpp:30:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d", &a[i].a, &a[i].b);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
examination.cpp:39:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d %d", &b[i].x, &b[i].y, &b[i].z);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 8 ms 760 KB Output is correct
8 Correct 9 ms 760 KB Output is correct
9 Correct 8 ms 760 KB Output is correct
10 Correct 7 ms 632 KB Output is correct
11 Correct 8 ms 760 KB Output is correct
12 Correct 5 ms 632 KB Output is correct
13 Correct 8 ms 760 KB Output is correct
14 Correct 8 ms 760 KB Output is correct
15 Correct 8 ms 760 KB Output is correct
16 Correct 7 ms 760 KB Output is correct
17 Correct 7 ms 632 KB Output is correct
18 Correct 5 ms 760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 265 ms 9176 KB Output is correct
2 Correct 262 ms 9192 KB Output is correct
3 Correct 264 ms 9172 KB Output is correct
4 Correct 209 ms 9000 KB Output is correct
5 Correct 212 ms 8936 KB Output is correct
6 Correct 111 ms 8532 KB Output is correct
7 Correct 251 ms 9156 KB Output is correct
8 Correct 250 ms 9172 KB Output is correct
9 Correct 231 ms 9052 KB Output is correct
10 Correct 196 ms 8772 KB Output is correct
11 Correct 198 ms 8732 KB Output is correct
12 Correct 88 ms 8256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 265 ms 9176 KB Output is correct
2 Correct 262 ms 9192 KB Output is correct
3 Correct 264 ms 9172 KB Output is correct
4 Correct 209 ms 9000 KB Output is correct
5 Correct 212 ms 8936 KB Output is correct
6 Correct 111 ms 8532 KB Output is correct
7 Correct 251 ms 9156 KB Output is correct
8 Correct 250 ms 9172 KB Output is correct
9 Correct 231 ms 9052 KB Output is correct
10 Correct 196 ms 8772 KB Output is correct
11 Correct 198 ms 8732 KB Output is correct
12 Correct 88 ms 8256 KB Output is correct
13 Correct 269 ms 9104 KB Output is correct
14 Correct 265 ms 9172 KB Output is correct
15 Correct 262 ms 9320 KB Output is correct
16 Correct 218 ms 8900 KB Output is correct
17 Correct 213 ms 8860 KB Output is correct
18 Correct 114 ms 8552 KB Output is correct
19 Correct 267 ms 9160 KB Output is correct
20 Correct 264 ms 9308 KB Output is correct
21 Correct 264 ms 9272 KB Output is correct
22 Correct 196 ms 8788 KB Output is correct
23 Correct 197 ms 8796 KB Output is correct
24 Correct 88 ms 8284 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 8 ms 760 KB Output is correct
8 Correct 9 ms 760 KB Output is correct
9 Correct 8 ms 760 KB Output is correct
10 Correct 7 ms 632 KB Output is correct
11 Correct 8 ms 760 KB Output is correct
12 Correct 5 ms 632 KB Output is correct
13 Correct 8 ms 760 KB Output is correct
14 Correct 8 ms 760 KB Output is correct
15 Correct 8 ms 760 KB Output is correct
16 Correct 7 ms 760 KB Output is correct
17 Correct 7 ms 632 KB Output is correct
18 Correct 5 ms 760 KB Output is correct
19 Correct 265 ms 9176 KB Output is correct
20 Correct 262 ms 9192 KB Output is correct
21 Correct 264 ms 9172 KB Output is correct
22 Correct 209 ms 9000 KB Output is correct
23 Correct 212 ms 8936 KB Output is correct
24 Correct 111 ms 8532 KB Output is correct
25 Correct 251 ms 9156 KB Output is correct
26 Correct 250 ms 9172 KB Output is correct
27 Correct 231 ms 9052 KB Output is correct
28 Correct 196 ms 8772 KB Output is correct
29 Correct 198 ms 8732 KB Output is correct
30 Correct 88 ms 8256 KB Output is correct
31 Correct 269 ms 9104 KB Output is correct
32 Correct 265 ms 9172 KB Output is correct
33 Correct 262 ms 9320 KB Output is correct
34 Correct 218 ms 8900 KB Output is correct
35 Correct 213 ms 8860 KB Output is correct
36 Correct 114 ms 8552 KB Output is correct
37 Correct 267 ms 9160 KB Output is correct
38 Correct 264 ms 9308 KB Output is correct
39 Correct 264 ms 9272 KB Output is correct
40 Correct 196 ms 8788 KB Output is correct
41 Correct 197 ms 8796 KB Output is correct
42 Correct 88 ms 8284 KB Output is correct
43 Correct 309 ms 9940 KB Output is correct
44 Correct 304 ms 10184 KB Output is correct
45 Correct 303 ms 10072 KB Output is correct
46 Correct 235 ms 9308 KB Output is correct
47 Correct 245 ms 9420 KB Output is correct
48 Correct 117 ms 8416 KB Output is correct
49 Correct 296 ms 10020 KB Output is correct
50 Correct 299 ms 10100 KB Output is correct
51 Correct 288 ms 10068 KB Output is correct
52 Correct 225 ms 9140 KB Output is correct
53 Correct 216 ms 9176 KB Output is correct