結果
| 問題 |
No.2897 2集合間距離
|
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2024-09-26 18:14:29 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,050 bytes |
| コンパイル時間 | 2,735 ms |
| コンパイル使用メモリ | 248,596 KB |
| 実行使用メモリ | 13,960 KB |
| 最終ジャッジ日時 | 2024-09-26 18:14:39 |
| 合計ジャッジ時間 | 8,498 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 16 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++){
auto p=upper_bound(vec[j].begin(),vec[j].end(),y[i]);
if(p!=vec[j].end()) res=min(res,abs(x[i]-j)+abs(y[i]-(*p)));
if(p!=vec[j].begin()) p--,res=min(res,abs(x[i]-j)+abs(y[i]-(*p)));
}
}
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