# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
557822 | hibiki | Examination (JOI19_examination) | C++11 | 523 ms | 1048576 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define PB push_back
#define F first
#define S second
const int MX_VAL = 1e9+7;
class FenwickTree
{
private:
int N;
vector<int> arr;
public:
FenwickTree() {}
FenwickTree(int n)
{
N=n;
arr.resize(n);
}
void update(int idx,int val)
{
idx++;
while(idx<N)
{
arr[idx] += val;
idx += idx & -idx;
}
return ;
}
int query(int idx)
{
idx++;
int ret=0;
while(idx>0)
{
ret += arr[idx];
idx -= idx & -idx;
}
return ret;
}
};
int n,q;
int sA[100005],sB[100005];
int qA[100005],qB[100005],qC[100005],ans[100005];
vector<pair<int,pair<int,int> > > poi;
int main()
{
scanf("%d %d",&n,&q);
for(int i=0;i<n;i++)
{
scanf("%d %d",&sA[i],&sB[i]);
poi.PB({ -(sA[i]+sB[i]) , {0,i} });
}
for(int i=0;i<q;i++)
{
scanf("%d %d %d",&qA[i],&qB[i],&qC[i]);
poi.PB({ -(max(qA[i]+qB[i],qC[i])) , {1,i} });
}
sort(poi.begin(),poi.end());
int all=0;
FenwickTree FwA(MX_VAL),FwB(MX_VAL);
for(int i=0;i<poi.size();i++)
{
int ty=poi[i].S.F;
int idx=poi[i].S.S;
if(!ty)
{
all++;
FwA.update(sA[idx],1);
FwB.update(sB[idx],1);
}
else
{
ans[idx] = all - FwA.query(max(0,qA[idx]-1)) - FwB.query(max(0,qB[idx]-1));
}
}
for(int i=0;i<q;i++)
printf("%d\n",ans[i]);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |