답안 #213250

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
213250 2020-03-25T11:17:36 Z zscoder Examination (JOI19_examination) C++17
100 / 100
329 ms 14876 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int ans[124455];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n, q; cin>>n>>q;
	vector<ii> v;
	vector<ii> v2;
	for(int i=0;i<n;i++)
	{
		int x,y; cin>>x>>y; v.pb({x,y}); v2.pb({x,x+y});
	}
	sort(v.begin(),v.end());
	sort(v2.begin(),v2.end());
	vector<pair<ii,int> > q1;
	vector<pair<ii,int> > q2;
	for(int i=0;i<q;i++)
	{
		int x,y,z; cin>>x>>y>>z;
		z=max(z,x+y);
		q2.pb({{x,z},i+1});
		q2.pb({{z-y,z},-(i+1)});
		q1.pb({{z-y,y},i+1});
	}
	sort(q1.rbegin(),q1.rend());
	sort(q2.rbegin(),q2.rend());
	int p=int(v.size())-1;
	int timer=0;
	pbds P;
	for(int z=0;z<q1.size();z++)
	{
		int x=q1[z].fi.fi; int y=q1[z].fi.se; int lab=q1[z].se;
		while(p>=0&&v[p].fi>=x)
		{
			P.insert(mp(v[p].se,++timer));
			p--;
		}
		int sign = (lab>0?1:-1);
		lab=abs(lab); lab--;
		int cnt = P.size() - P.order_of_key(mp(y,-10000));
		ans[lab]+=sign*cnt;
	}
	swap(q1,q2);
	P.clear();
	p=int(v2.size())-1;
	for(int z=0;z<q1.size();z++)
	{
		int x=q1[z].fi.fi; int y=q1[z].fi.se; int lab=q1[z].se;
		while(p>=0&&v2[p].fi>=x)
		{
			P.insert(mp(v2[p].se,++timer));
			p--;
		}
		int sign = (lab>0?1:-1);
		lab=abs(lab); lab--;
		int cnt = P.size() - P.order_of_key(mp(y,-10000));
		ans[lab]+=sign*cnt;
	}
	for(int i=0;i<q;i++)
	{
		cout<<ans[i]<<'\n';
	}
}

Compilation message

examination.cpp: In function 'int main()':
examination.cpp:49:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int z=0;z<q1.size();z++)
              ~^~~~~~~~~~
examination.cpp:65:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int z=0;z<q1.size();z++)
              ~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 10 ms 768 KB Output is correct
8 Correct 10 ms 896 KB Output is correct
9 Correct 10 ms 896 KB Output is correct
10 Correct 9 ms 768 KB Output is correct
11 Correct 10 ms 768 KB Output is correct
12 Correct 9 ms 768 KB Output is correct
13 Correct 10 ms 896 KB Output is correct
14 Correct 11 ms 896 KB Output is correct
15 Correct 11 ms 796 KB Output is correct
16 Correct 9 ms 768 KB Output is correct
17 Correct 9 ms 768 KB Output is correct
18 Correct 9 ms 768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 298 ms 14556 KB Output is correct
2 Correct 286 ms 14680 KB Output is correct
3 Correct 299 ms 14688 KB Output is correct
4 Correct 240 ms 14624 KB Output is correct
5 Correct 206 ms 14424 KB Output is correct
6 Correct 180 ms 13652 KB Output is correct
7 Correct 299 ms 14876 KB Output is correct
8 Correct 260 ms 14684 KB Output is correct
9 Correct 272 ms 14808 KB Output is correct
10 Correct 180 ms 14296 KB Output is correct
11 Correct 219 ms 14300 KB Output is correct
12 Correct 195 ms 13404 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 298 ms 14556 KB Output is correct
2 Correct 286 ms 14680 KB Output is correct
3 Correct 299 ms 14688 KB Output is correct
4 Correct 240 ms 14624 KB Output is correct
5 Correct 206 ms 14424 KB Output is correct
6 Correct 180 ms 13652 KB Output is correct
7 Correct 299 ms 14876 KB Output is correct
8 Correct 260 ms 14684 KB Output is correct
9 Correct 272 ms 14808 KB Output is correct
10 Correct 180 ms 14296 KB Output is correct
11 Correct 219 ms 14300 KB Output is correct
12 Correct 195 ms 13404 KB Output is correct
13 Correct 304 ms 14720 KB Output is correct
14 Correct 322 ms 14680 KB Output is correct
15 Correct 297 ms 14788 KB Output is correct
16 Correct 245 ms 14764 KB Output is correct
17 Correct 215 ms 14772 KB Output is correct
18 Correct 181 ms 13784 KB Output is correct
19 Correct 299 ms 14680 KB Output is correct
20 Correct 301 ms 14680 KB Output is correct
21 Correct 299 ms 14680 KB Output is correct
22 Correct 181 ms 14300 KB Output is correct
23 Correct 225 ms 14340 KB Output is correct
24 Correct 188 ms 13328 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 10 ms 768 KB Output is correct
8 Correct 10 ms 896 KB Output is correct
9 Correct 10 ms 896 KB Output is correct
10 Correct 9 ms 768 KB Output is correct
11 Correct 10 ms 768 KB Output is correct
12 Correct 9 ms 768 KB Output is correct
13 Correct 10 ms 896 KB Output is correct
14 Correct 11 ms 896 KB Output is correct
15 Correct 11 ms 796 KB Output is correct
16 Correct 9 ms 768 KB Output is correct
17 Correct 9 ms 768 KB Output is correct
18 Correct 9 ms 768 KB Output is correct
19 Correct 298 ms 14556 KB Output is correct
20 Correct 286 ms 14680 KB Output is correct
21 Correct 299 ms 14688 KB Output is correct
22 Correct 240 ms 14624 KB Output is correct
23 Correct 206 ms 14424 KB Output is correct
24 Correct 180 ms 13652 KB Output is correct
25 Correct 299 ms 14876 KB Output is correct
26 Correct 260 ms 14684 KB Output is correct
27 Correct 272 ms 14808 KB Output is correct
28 Correct 180 ms 14296 KB Output is correct
29 Correct 219 ms 14300 KB Output is correct
30 Correct 195 ms 13404 KB Output is correct
31 Correct 304 ms 14720 KB Output is correct
32 Correct 322 ms 14680 KB Output is correct
33 Correct 297 ms 14788 KB Output is correct
34 Correct 245 ms 14764 KB Output is correct
35 Correct 215 ms 14772 KB Output is correct
36 Correct 181 ms 13784 KB Output is correct
37 Correct 299 ms 14680 KB Output is correct
38 Correct 301 ms 14680 KB Output is correct
39 Correct 299 ms 14680 KB Output is correct
40 Correct 181 ms 14300 KB Output is correct
41 Correct 225 ms 14340 KB Output is correct
42 Correct 188 ms 13328 KB Output is correct
43 Correct 314 ms 14552 KB Output is correct
44 Correct 306 ms 14556 KB Output is correct
45 Correct 311 ms 14684 KB Output is correct
46 Correct 235 ms 14552 KB Output is correct
47 Correct 227 ms 14552 KB Output is correct
48 Correct 177 ms 13532 KB Output is correct
49 Correct 329 ms 14680 KB Output is correct
50 Correct 284 ms 14428 KB Output is correct
51 Correct 306 ms 14556 KB Output is correct
52 Correct 246 ms 14300 KB Output is correct
53 Correct 237 ms 14296 KB Output is correct