# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
557822 | hibiki | Examination (JOI19_examination) | C++11 | 523 ms | 1048576 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
컴파일 시 표준 에러 (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... |