QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#765082#9623. 合成大西瓜Heenpei#RE 0ms7600kbC++231.7kb2024-11-20 11:59:202024-11-20 11:59:21

Judging History

This is the latest submission verdict.

  • [2024-11-20 11:59:21]
  • Judged
  • Verdict: RE
  • Time: 0ms
  • Memory: 7600kb
  • [2024-11-20 11:59:20]
  • Submitted

answer

#include<bits/stdc++.h>
#define endl '\n'
#define ll  long long
#define Int __int128
#define pb push_back
#define eb emplace_back
#define MAX_LOG 21
#define ff first
#define ss second
#define M (int)1e4+10
#define ull unsigned long long
#define MAX_LOG 21
//#define double long double
using namespace std;
const double PI=3.1415926535897932385;
const int IIMIN=-2147483648;
//const ll p=998244353;
const ll mod=1e9+7;
const int INF=0x3f3f3f3f;
typedef pair<ll,ll> PLL;
typedef pair<double,double>PFF;
ll gcd(ll a,ll b)
{
    if(b) while((a%=b)&&(b%=a));
    return a+b;
}//最大公约数函数
ll spid(ll a,ll b,ll p)
{
    ll ans=1;
    while(b)
    {
        if(b&1)ans=ans*a%p;
        b>>=1;
        a=a*a%p;
    }
    return ans;
}//快速幂函数
///小香猪的代码块·香香猪猪惹人怜~
///秋雨想睡觉
const ll N =4e5+10;
ll a[N];
ll du[N];
vector<ll>go[N];
void solve()
{
    ll n,m;cin>>n>>m;
    for(int i=1;i<=n;i++)cin>>a[i];
    while(m--)
    {
        ll u,v;cin>>u>>v;
        du[u]++;du[v]++;
        go[u].eb(v);
        go[v].eb(u);
    }
    ll max_=0,min_=0;
    vector<ll>vec;
    for(int i=1;i<=n;i++)
    {
        if(du[i]>=2)max_=max(a[i],max_);
        else vec.eb(a[i]);
    }
    sort(vec.begin(),vec.end());
    reverse(vec.begin(),vec.end());
    ll len=vec.size();
    if(len>=2)min_=min(vec[0],vec[1]);
    else min_=vec[0];
    cout<<max(max_,min_);
}
///秋雨睡觉了
//7 7
//1 1 2 3 1 2 1
//1 2
//2 3
//1 3
//2 4
//2 5
//5 6
//5 7
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t=1;
//    cin>>t;
    while(t--)
    {
        solve();
    }
}
///记忆是梦的开场白
/*
  */

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 7600kb

input:

7 9
1 4 1 3 3 6 7
5 4
3 6
3 4
2 3
5 2
2 6
6 7
5 1
4 6

output:

6

result:

ok single line: '6'

Test #2:

score: -100
Runtime Error

input:

5 7
1 5 3 1 4
3 5
1 3
5 1
1 4
5 4
2 4
3 2

output:


result: