답안 #119008

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
119008 2019-06-20T07:28:10 Z raghav0307 Examination (JOI19_examination) C++14
0 / 100
73 ms 6500 KB
/*raghav0307 - Raghav Gupta*/

#include <bits/stdc++.h>
using namespace std;

#define ff first
#define ss second
#define pb push_back
#define fast_io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
#define int ll
const int MAXN = 1e5 + 5;

int bit[MAXN];

void add(int pos, int delta){
	for( ; pos < MAXN; pos = pos | ( pos + 1))
		bit[pos] += delta;
}

int sum(int pos){
	int ans = 0;
	for( ; pos >= 0; pos = (pos & (pos+1)) - 1)
		ans += bit[pos];
	return ans;
}

int sum(int l, int r){
	return sum(r) - sum(l-1);
}

signed main(){
	fast_io();
	int n, q;
	cin >> n >> q;
	pair<int, int> score[n];
	for(int i = 0; i < n; i++){
		cin >> score[i].ff >> score[i].ss;
	}
	sort(score, score + n);
	vector<pair<pii, int> > criter;
	int ans[q];
	for(int i = 0; i < q; i++){
		int x, y , z;
		cin >> x >> y >> z;
		criter.pb({{x,y}, i});
	}
	sort(criter.begin(), criter.end());
	int at = n-1;
	while(!criter.empty()){
		auto x = criter.back(); criter.pop_back();
		while(at >= 0 and score[at].ff >= x.ff.ff){
			add(score[at].ss, 1);
			at--;
		}
		ans[x.ss] = sum(x.ff.ss, MAXN);
	}
	for(int i = 0; i < q; i++)
		cout << ans[i] << "\n";
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 73 ms 6500 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 73 ms 6500 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -