이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<stdio.h>
#include<algorithm>
#include<vector>
#define X first
#define Y second
typedef long long ll;
typedef std::pair<int,int> Pi;
const int ML = 10001;
int n;
std::vector <int> v[10010];
struct BIT{
static const int N_ = 10010;
ll T[N_];
void update(int x,int v){for(int i=x;i;i-=(i&-i))T[i] += v;}
void update(int x0,int x1,int v){update(x1,v),update(x0-1,-v);}
ll read(int x){
ll res = 0;
for(int i=x;i&&i<N_;i+=(i&-i))res += T[i];
return res;
}
};
struct BIT2{
BIT T0, T1;
void update(int x,int a){
T0.update(x+1, ML, -x*a);
T0.update(1, x, x*a);
T1.update(x+1, ML, a);
T1.update(1, x, -a);
}
ll read(int x){
return T0.read(x) + T1.read(x) * x;
}
}tr[2];
ll ans;
int main()
{
scanf("%d",&n);
int i;
for(i=0;i<n;i++){
int x,y;
scanf("%d%d",&x,&y);
v[x].push_back(y);
}
for(int u=1;u<ML;u++){
for(i=0;i<v[u].size();i++){
int t = v[u][i];
tr[0].update(t, ML - u);
tr[1].update(t, 1);
ans += tr[0].read(t) - tr[1].read(t) * (ML - u);
}
}
printf("%lld",ans);
return 0;
}
| # | 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... |