답안 #260027

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
260027 2020-08-09T03:16:48 Z minhcool Examination (JOI19_examination) C++17
2 / 100
98 ms 14072 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)) ++BIT[u];
}

int get(int u){
	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;
	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;
			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++){
			int z;
			cin >> queries[i].fi.fi >> queries[i].fi.se >> z;
			queries[i].se = i;
		}
		sort(queries + 1, queries + q + 1, cmp);
		int itr = 1;
		for(int i = 1; i <= q; i++){
			while(itr <= n && students[itr].fi >= queries[i].fi.fi){
				update(students[itr].se);
				++itr;
			}
			ans[queries[i].se] = get(100000) - get(queries[i].fi.se - 1);
		}
		for(int i = 1; i <= q; i++) cout << ans[i] << "\n";
	}
}

# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 34 ms 612 KB Output is correct
8 Correct 33 ms 512 KB Output is correct
9 Correct 34 ms 640 KB Output is correct
10 Correct 32 ms 512 KB Output is correct
11 Correct 32 ms 512 KB Output is correct
12 Correct 32 ms 384 KB Output is correct
13 Correct 33 ms 512 KB Output is correct
14 Correct 33 ms 532 KB Output is correct
15 Correct 33 ms 640 KB Output is correct
16 Correct 23 ms 512 KB Output is correct
17 Correct 24 ms 512 KB Output is correct
18 Correct 22 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 98 ms 14072 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 98 ms 14072 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 34 ms 612 KB Output is correct
8 Correct 33 ms 512 KB Output is correct
9 Correct 34 ms 640 KB Output is correct
10 Correct 32 ms 512 KB Output is correct
11 Correct 32 ms 512 KB Output is correct
12 Correct 32 ms 384 KB Output is correct
13 Correct 33 ms 512 KB Output is correct
14 Correct 33 ms 532 KB Output is correct
15 Correct 33 ms 640 KB Output is correct
16 Correct 23 ms 512 KB Output is correct
17 Correct 24 ms 512 KB Output is correct
18 Correct 22 ms 384 KB Output is correct
19 Runtime error 98 ms 14072 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Halted 0 ms 0 KB -