結果
| 問題 |
No.2897 2集合間距離
|
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2024-09-26 18:48:59 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,140 bytes |
| コンパイル時間 | 3,402 ms |
| コンパイル使用メモリ | 247,004 KB |
| 実行使用メモリ | 11,264 KB |
| 最終ジャッジ日時 | 2024-09-26 18:49:12 |
| 合計ジャッジ時間 | 9,156 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 11 WA * 5 TLE * 1 -- * 7 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define sc second
#define pii pair<int,int>
#define pb push_back
#define umap unordered_map
#define mset multiset
#define pq priority_queue
#define ull unsigned long long
#define i128 __int128
const int maxn=2e5+10;
int n,x[maxn],m,y[maxn];
vector<int> vec[maxn];
void solve(){
cin>>n;
for(int i=1;i<=n;i++) cin>>x[i]>>y[i];
cin>>m;
for(int i=1;i<=m;i++){
int a,b;
cin>>a>>b;
vec[a].pb(b);
}
int res=1e9;
for(int i=1;i<=n;i++){
for(int j=0;j<=1e3;j++){
if(vec[j].empty()) continue;
auto p1=upper_bound(vec[j].begin(),vec[j].end(),y[i]),p2=lower_bound(vec[j].begin(),vec[j].end(),y[i]);
if(p1!=vec[j].end()) res=min(res,abs(x[i]-j)+abs(y[i]-(*p1)));
if(p2!=vec[j].end()) res=min(res,abs(x[i]-j)+abs(y[i]-(*p2)));
}
}
cout<<res<<endl;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
int t=1;
// cin>>t;
while(t--) solve();
return 0;
}
/*
Samples
input:
output:
THINGS TODO:
??freopen???????
????
????????????
*/
vjudge1