Submission #557831

# Submission time Handle Problem Language Result Execution time Memory
557831 2022-05-06T06:16:13 Z hibiki Examination (JOI19_examination) C++11
100 / 100
342 ms 22928 KB
#include<bits/stdc++.h>
using namespace std;

#define PB push_back
#define F first
#define S second

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int n,q;
int sA[100005],sB[100005];
int qA[100005],qB[100005],qC[100005],ans[100005];
vector<pair<int,pair<int,int> > > poi;

int main()
{
    scanf("%d %d",&n,&q);
    for(int i=0;i<n;i++)
    {
        scanf("%d %d",&sA[i],&sB[i]);
        poi.PB({ -(sA[i]+sB[i]) , {0,i} });
    }
    for(int i=0;i<q;i++)
    {
        scanf("%d %d %d",&qA[i],&qB[i],&qC[i]);
        poi.PB({ -max(qA[i]+qB[i],qC[i]) , {1,i} });
    }

    sort(poi.begin(),poi.end());

    int all=0;
    ordered_set<pair<int,int> > oA,oB;
    for(int i=0;i<poi.size();i++)
    {
        int ty=poi[i].S.F;
        int idx=poi[i].S.S;
        if(!ty)
        {
            all++;
            oA.insert({sA[idx],idx});
            oB.insert({sB[idx],idx});
        }
        else
        {
            ans[idx] = all - oA.order_of_key({qA[idx],0}) - oB.order_of_key({qB[idx],0});
        }
    }

    for(int i=0;i<q;i++)
        printf("%d\n",ans[i]);

    return 0;
}

Compilation message

examination.cpp: In function 'int main()':
examination.cpp:37:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |     for(int i=0;i<poi.size();i++)
      |                 ~^~~~~~~~~~~
examination.cpp:21:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |     scanf("%d %d",&n,&q);
      |     ~~~~~^~~~~~~~~~~~~~~
examination.cpp:24:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |         scanf("%d %d",&sA[i],&sB[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
examination.cpp:29:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |         scanf("%d %d %d",&qA[i],&qB[i],&qC[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 6 ms 956 KB Output is correct
8 Correct 6 ms 980 KB Output is correct
9 Correct 5 ms 932 KB Output is correct
10 Correct 5 ms 852 KB Output is correct
11 Correct 5 ms 960 KB Output is correct
12 Correct 7 ms 844 KB Output is correct
13 Correct 7 ms 956 KB Output is correct
14 Correct 6 ms 964 KB Output is correct
15 Correct 6 ms 980 KB Output is correct
16 Correct 5 ms 852 KB Output is correct
17 Correct 4 ms 960 KB Output is correct
18 Correct 4 ms 852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 314 ms 18316 KB Output is correct
2 Correct 318 ms 18364 KB Output is correct
3 Correct 316 ms 20556 KB Output is correct
4 Correct 208 ms 19796 KB Output is correct
5 Correct 219 ms 19808 KB Output is correct
6 Correct 202 ms 19112 KB Output is correct
7 Correct 278 ms 20532 KB Output is correct
8 Correct 300 ms 20404 KB Output is correct
9 Correct 252 ms 20412 KB Output is correct
10 Correct 204 ms 19524 KB Output is correct
11 Correct 209 ms 19588 KB Output is correct
12 Correct 215 ms 18716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 314 ms 18316 KB Output is correct
2 Correct 318 ms 18364 KB Output is correct
3 Correct 316 ms 20556 KB Output is correct
4 Correct 208 ms 19796 KB Output is correct
5 Correct 219 ms 19808 KB Output is correct
6 Correct 202 ms 19112 KB Output is correct
7 Correct 278 ms 20532 KB Output is correct
8 Correct 300 ms 20404 KB Output is correct
9 Correct 252 ms 20412 KB Output is correct
10 Correct 204 ms 19524 KB Output is correct
11 Correct 209 ms 19588 KB Output is correct
12 Correct 215 ms 18716 KB Output is correct
13 Correct 297 ms 21076 KB Output is correct
14 Correct 342 ms 20928 KB Output is correct
15 Correct 313 ms 20536 KB Output is correct
16 Correct 214 ms 20104 KB Output is correct
17 Correct 217 ms 20152 KB Output is correct
18 Correct 182 ms 19028 KB Output is correct
19 Correct 311 ms 20964 KB Output is correct
20 Correct 271 ms 20960 KB Output is correct
21 Correct 324 ms 20876 KB Output is correct
22 Correct 193 ms 19604 KB Output is correct
23 Correct 223 ms 19640 KB Output is correct
24 Correct 224 ms 18656 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 6 ms 956 KB Output is correct
8 Correct 6 ms 980 KB Output is correct
9 Correct 5 ms 932 KB Output is correct
10 Correct 5 ms 852 KB Output is correct
11 Correct 5 ms 960 KB Output is correct
12 Correct 7 ms 844 KB Output is correct
13 Correct 7 ms 956 KB Output is correct
14 Correct 6 ms 964 KB Output is correct
15 Correct 6 ms 980 KB Output is correct
16 Correct 5 ms 852 KB Output is correct
17 Correct 4 ms 960 KB Output is correct
18 Correct 4 ms 852 KB Output is correct
19 Correct 314 ms 18316 KB Output is correct
20 Correct 318 ms 18364 KB Output is correct
21 Correct 316 ms 20556 KB Output is correct
22 Correct 208 ms 19796 KB Output is correct
23 Correct 219 ms 19808 KB Output is correct
24 Correct 202 ms 19112 KB Output is correct
25 Correct 278 ms 20532 KB Output is correct
26 Correct 300 ms 20404 KB Output is correct
27 Correct 252 ms 20412 KB Output is correct
28 Correct 204 ms 19524 KB Output is correct
29 Correct 209 ms 19588 KB Output is correct
30 Correct 215 ms 18716 KB Output is correct
31 Correct 297 ms 21076 KB Output is correct
32 Correct 342 ms 20928 KB Output is correct
33 Correct 313 ms 20536 KB Output is correct
34 Correct 214 ms 20104 KB Output is correct
35 Correct 217 ms 20152 KB Output is correct
36 Correct 182 ms 19028 KB Output is correct
37 Correct 311 ms 20964 KB Output is correct
38 Correct 271 ms 20960 KB Output is correct
39 Correct 324 ms 20876 KB Output is correct
40 Correct 193 ms 19604 KB Output is correct
41 Correct 223 ms 19640 KB Output is correct
42 Correct 224 ms 18656 KB Output is correct
43 Correct 287 ms 22892 KB Output is correct
44 Correct 299 ms 22928 KB Output is correct
45 Correct 302 ms 22868 KB Output is correct
46 Correct 263 ms 21380 KB Output is correct
47 Correct 263 ms 21348 KB Output is correct
48 Correct 199 ms 18876 KB Output is correct
49 Correct 309 ms 22836 KB Output is correct
50 Correct 290 ms 22808 KB Output is correct
51 Correct 309 ms 22656 KB Output is correct
52 Correct 253 ms 21224 KB Output is correct
53 Correct 242 ms 20420 KB Output is correct