mirror of
https://gitcode.com/Zengtudor/alg2025.git
synced 2025-08-21 18:52:07 +00:00
50 lines
1006 B
C++
50 lines
1006 B
C++
#include <algorithm>
|
|
#include <cstdint>
|
|
#include <iostream>
|
|
#include <queue>
|
|
#include <utility>
|
|
#include <vector>
|
|
|
|
using ll = int64_t;
|
|
|
|
ll t;
|
|
bool isfirst = true;
|
|
|
|
void solve(){
|
|
ll n;
|
|
std::cin>>n;
|
|
static std::vector<ll> a;
|
|
a.resize(n+1);
|
|
if(isfirst){
|
|
isfirst=false;
|
|
for(ll i=1;i<=n;i++){
|
|
std::cin>>a[i];
|
|
}
|
|
}else{
|
|
for(ll i=1;i<=n;i++){
|
|
ll x,y;
|
|
std::cin>>x>>y;
|
|
a[x]=y;
|
|
}
|
|
}
|
|
static std::vector<std::pair<ll, ll>> na;
|
|
na.resize(a.size());
|
|
for(ll i=1;i<a.size();i++){
|
|
na[i].first = a[i];
|
|
na[i].second=i;
|
|
}
|
|
std::sort(na.begin()+1,na.end());
|
|
// for(auto[x,y]:na)std::cout<<"("<<x<<","<<y<<"),";
|
|
if(na[3].first-na[1].first>na[2].first || (na[3].first-na[1].first == na[2].first && na[3].second>na[1].second)){
|
|
std::cout<<1<<'\n';
|
|
}else{
|
|
std::cout<<3<<'\n';
|
|
}
|
|
}
|
|
|
|
int main(){
|
|
std::cin>>t;
|
|
while(t--){
|
|
solve();
|
|
}
|
|
} |