답안 #443952

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
443952 2021-07-12T15:42:06 Z Jasiekstrz Examination (JOI19_examination) C++17
100 / 100
413 ms 29564 KB
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define fi first
#define se second
using namespace std;
using namespace __gnu_pbds;
const int N=1e5;
struct Que
{
	int x,y,z;
	int id;
};
tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> os,osa,osb;
vector<Que> type1,type2;
int ans[N+10];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,q;
	cin>>n>>q;
	for(int i=1;i<=n;i++)
	{
		int x,y;
		cin>>x>>y;
		type1.push_back({x,y,x+y,0});
		type2.push_back({x,y,x+y,0});
	}
	for(int i=1;i<=q;i++)
	{
		int x,y,z;
		cin>>x>>y>>z;
		if(x+y>=z)
			type1.push_back({x,y,z,i});
		else
			type2.push_back({x,y,z,i});
	}
	int it=0;
	
	// TYPE 1 (z not important)
	sort(type1.begin(),type1.end(),[](Que &a,Que &b){return (a.x>b.x || (a.x==b.x && a.id<b.id));});
	for(auto v:type1)
	{
		if(v.id==0)
			os.insert({v.y,++it});
		else
		{
			ans[v.id]=os.size()-os.order_of_key({v.y,0});
			//cerr<<"type1 "<<v.id<<" "<<os.size()<<" "<<os.order_of_key({v.y,0})<<"\n";
		}
	}

	// TYPE 2 (z important)
	sort(type2.begin(),type2.end(),[](Que &a,Que &b){return (a.z>b.z || (a.z==b.z && a.id<b.id));});
	for(auto v:type2)
	{
		if(v.id==0)
		{
			osa.insert({v.x,++it});
			osb.insert({v.y,++it});
		}
		else
		{
			ans[v.id]=osa.size()-osa.order_of_key({v.x,0})-osb.order_of_key({v.y,0});
			//cerr<<"type2 "<<v.id<<" "<<os.size()<<" "<<os.order_of_key({v.y,0})<<"\n";
		}
	}

	for(int i=1;i<=q;i++)
		cout<<ans[i]<<"\n";
	return 0;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 324 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 6 ms 1100 KB Output is correct
8 Correct 6 ms 1096 KB Output is correct
9 Correct 6 ms 1100 KB Output is correct
10 Correct 7 ms 1100 KB Output is correct
11 Correct 6 ms 1100 KB Output is correct
12 Correct 6 ms 1028 KB Output is correct
13 Correct 6 ms 1100 KB Output is correct
14 Correct 6 ms 1100 KB Output is correct
15 Correct 6 ms 1100 KB Output is correct
16 Correct 6 ms 1100 KB Output is correct
17 Correct 6 ms 1100 KB Output is correct
18 Correct 6 ms 1028 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 300 ms 27400 KB Output is correct
2 Correct 301 ms 27156 KB Output is correct
3 Correct 306 ms 27336 KB Output is correct
4 Correct 247 ms 26516 KB Output is correct
5 Correct 263 ms 26508 KB Output is correct
6 Correct 258 ms 25736 KB Output is correct
7 Correct 307 ms 27096 KB Output is correct
8 Correct 313 ms 27248 KB Output is correct
9 Correct 305 ms 27112 KB Output is correct
10 Correct 281 ms 26272 KB Output is correct
11 Correct 276 ms 26336 KB Output is correct
12 Correct 273 ms 25296 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 300 ms 27400 KB Output is correct
2 Correct 301 ms 27156 KB Output is correct
3 Correct 306 ms 27336 KB Output is correct
4 Correct 247 ms 26516 KB Output is correct
5 Correct 263 ms 26508 KB Output is correct
6 Correct 258 ms 25736 KB Output is correct
7 Correct 307 ms 27096 KB Output is correct
8 Correct 313 ms 27248 KB Output is correct
9 Correct 305 ms 27112 KB Output is correct
10 Correct 281 ms 26272 KB Output is correct
11 Correct 276 ms 26336 KB Output is correct
12 Correct 273 ms 25296 KB Output is correct
13 Correct 413 ms 27560 KB Output is correct
14 Correct 329 ms 27528 KB Output is correct
15 Correct 343 ms 27192 KB Output is correct
16 Correct 252 ms 26868 KB Output is correct
17 Correct 263 ms 26784 KB Output is correct
18 Correct 248 ms 25752 KB Output is correct
19 Correct 313 ms 27668 KB Output is correct
20 Correct 317 ms 27596 KB Output is correct
21 Correct 335 ms 27712 KB Output is correct
22 Correct 254 ms 26264 KB Output is correct
23 Correct 267 ms 26236 KB Output is correct
24 Correct 292 ms 25324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 324 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 6 ms 1100 KB Output is correct
8 Correct 6 ms 1096 KB Output is correct
9 Correct 6 ms 1100 KB Output is correct
10 Correct 7 ms 1100 KB Output is correct
11 Correct 6 ms 1100 KB Output is correct
12 Correct 6 ms 1028 KB Output is correct
13 Correct 6 ms 1100 KB Output is correct
14 Correct 6 ms 1100 KB Output is correct
15 Correct 6 ms 1100 KB Output is correct
16 Correct 6 ms 1100 KB Output is correct
17 Correct 6 ms 1100 KB Output is correct
18 Correct 6 ms 1028 KB Output is correct
19 Correct 300 ms 27400 KB Output is correct
20 Correct 301 ms 27156 KB Output is correct
21 Correct 306 ms 27336 KB Output is correct
22 Correct 247 ms 26516 KB Output is correct
23 Correct 263 ms 26508 KB Output is correct
24 Correct 258 ms 25736 KB Output is correct
25 Correct 307 ms 27096 KB Output is correct
26 Correct 313 ms 27248 KB Output is correct
27 Correct 305 ms 27112 KB Output is correct
28 Correct 281 ms 26272 KB Output is correct
29 Correct 276 ms 26336 KB Output is correct
30 Correct 273 ms 25296 KB Output is correct
31 Correct 413 ms 27560 KB Output is correct
32 Correct 329 ms 27528 KB Output is correct
33 Correct 343 ms 27192 KB Output is correct
34 Correct 252 ms 26868 KB Output is correct
35 Correct 263 ms 26784 KB Output is correct
36 Correct 248 ms 25752 KB Output is correct
37 Correct 313 ms 27668 KB Output is correct
38 Correct 317 ms 27596 KB Output is correct
39 Correct 335 ms 27712 KB Output is correct
40 Correct 254 ms 26264 KB Output is correct
41 Correct 267 ms 26236 KB Output is correct
42 Correct 292 ms 25324 KB Output is correct
43 Correct 317 ms 29532 KB Output is correct
44 Correct 317 ms 29528 KB Output is correct
45 Correct 325 ms 29564 KB Output is correct
46 Correct 317 ms 28076 KB Output is correct
47 Correct 315 ms 28136 KB Output is correct
48 Correct 245 ms 25760 KB Output is correct
49 Correct 341 ms 29476 KB Output is correct
50 Correct 322 ms 29500 KB Output is correct
51 Correct 343 ms 29412 KB Output is correct
52 Correct 297 ms 27856 KB Output is correct
53 Correct 374 ms 27056 KB Output is correct