Submission #260028

# Submission time Handle Problem Language Result Execution time Memory
260028 2020-08-09T03:35:27 Z minhcool Examination (JOI19_examination) C++17
2 / 100
101 ms 6392 KB
#include<bits/stdc++.h>
using namespace std;

#define int long long
#define fi first
#define se second
#define pb push_back
#define ins insert
#define er erase

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;

const int oo = 1e18 + 7, mod = 1e9 + 7;

const int N = 1e5 + 5;

int n, q, BIT[N], ans[N];
iii queries[N];
ii students[N];

void update(int u){
	for(; u <= 100000 && u; u += (u & -u)){
		//cout << u << " " << u + (u & -u) << "\n";
		++BIT[u];
	}
}

int get(int u){
	if(u < 0) return 0;
	int sum = 0;
	for(; u; u -= (u & -u)) sum += BIT[u];
	return sum;
}

bool cmp(iii a, iii b){
	if(a.fi != b.fi) return a.fi > b.fi;
	return 0;
}

signed main(){
	ios_base::sync_with_stdio(0);
	//freopen("examination_19.inp", "r", stdin);
	//freopen("examination_19.out", "w", stdout);
	cin >> n >> q;
	for(int i = 1; i <= n; i++){
		cin >> students[i].fi >> students[i].se;
		++students[i].fi;
		++students[i].se;
	}
	sort(students + 1, students + n + 1, greater<ii>());
	if(n <= 3000 && q <= 3000){
		while(q--){
			int x, y, z, ans = 0;
			cin >> x >> y >> z;
			++x;
			++y;
			z += 2;
			for(int i = 1; i <= n; i++) ans += (x <= students[i].fi && y <= students[i].se && z <= (students[i].fi + students[i].se));
			cout << ans << "\n";
		}
	}
	else{
		for(int i = 1; i <= q; i++){
			//cout << i << "\n";
			int z;
			cin >> queries[i].fi.fi >> queries[i].fi.se >> z;
			++queries[i].fi.fi;
			++queries[i].fi.se;
			queries[i].se = i;
		}
		sort(queries + 1, queries + q + 1, cmp);
		int itr = 1;
		for(int i = 1; i <= q; i++){
			//cout << i << "\n";
			while(itr <= n && students[itr].fi >= queries[i].fi.fi){
				update(students[itr].se);
				++itr;
				//cout << itr << "\n";
			}
			ans[queries[i].se] = get(100002) - get(queries[i].fi.se - 1);
		}
		for(int i = 1; i <= q; i++) cout << ans[i] << "\n";
	}
}

# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 29 ms 384 KB Output is correct
8 Correct 29 ms 384 KB Output is correct
9 Correct 29 ms 416 KB Output is correct
10 Correct 28 ms 384 KB Output is correct
11 Correct 19 ms 384 KB Output is correct
12 Correct 18 ms 384 KB Output is correct
13 Correct 29 ms 384 KB Output is correct
14 Correct 29 ms 384 KB Output is correct
15 Correct 29 ms 384 KB Output is correct
16 Correct 21 ms 504 KB Output is correct
17 Correct 19 ms 384 KB Output is correct
18 Correct 21 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 101 ms 6392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 101 ms 6392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 29 ms 384 KB Output is correct
8 Correct 29 ms 384 KB Output is correct
9 Correct 29 ms 416 KB Output is correct
10 Correct 28 ms 384 KB Output is correct
11 Correct 19 ms 384 KB Output is correct
12 Correct 18 ms 384 KB Output is correct
13 Correct 29 ms 384 KB Output is correct
14 Correct 29 ms 384 KB Output is correct
15 Correct 29 ms 384 KB Output is correct
16 Correct 21 ms 504 KB Output is correct
17 Correct 19 ms 384 KB Output is correct
18 Correct 21 ms 384 KB Output is correct
19 Incorrect 101 ms 6392 KB Output isn't correct
20 Halted 0 ms 0 KB -