結果
| 問題 |
No.2897 2集合間距離
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-09-20 22:08:24 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,072 bytes |
| コンパイル時間 | 1,343 ms |
| コンパイル使用メモリ | 127,692 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-20 22:08:28 |
| 合計ジャッジ時間 | 3,127 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 1 WA * 23 |
ソースコード
// #define _GLIBCXX_DEBUG
// #include<bits/stdc++.h>
#include<iostream>
#include<cassert>
#include<iomanip>
using namespace std;
#include<atcoder/segtree>
int N,M;
long long ans=0;
using S=pair<long long,int>;
S op(S l, S r){ return S{l.first+r.first, l.second+r.second}; }
S e(void){ return S{0LL,0}; }
int main(void){
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout<<fixed<<setprecision(15);
atcoder::segtree<S,op,e> seg_x(1009),seg_y(1009);
cin>>N;
for(int i=0;i<N;i++){
int x,y;cin>>x>>y;
auto [sum,cnt]=seg_x.get(x);
seg_x.set(x, S{sum+x, ++cnt});
tie(sum,cnt)=seg_y.get(y);
seg_y.set(y, S{sum+y, ++cnt});
}
cin>>M;
for(int i=0;i<M;i++){
int x,y;cin>>x>>y;
{
// smaller
auto [sum,cnt]=seg_x.prod(0, x);
ans+=x*cnt-sum;
// larger
tie(sum,cnt)=seg_x.prod(x, 1009);
ans+=x*cnt-sum;
}
{
// smaller
auto [sum,cnt]=seg_y.prod(0, y);
ans+=y*cnt-sum;
// larger
tie(sum,cnt)=seg_y.prod(y, 1009);
ans+=y*cnt-sum;
}
}
cout<<ans<<endl;
}