QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#788448 | #9623. 合成大西瓜 | Godwang# | RE | 1ms | 5672kb | C++23 | 1.2kb | 2024-11-27 16:59:18 | 2024-11-27 16:59:19 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=n;i>=a;i--)
#define endl '\n'
#define ll long long
#define pb push_back
const int N=1e6+10;
//////////////////
int n,m;
int a[N];
int d[N];
vector<int > v;
/////////////////
bool cmp(int x,int y)
{
return x>y;
}
/////////////////
void init()
{
}
/////////////////
int main()
{
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
// freopen("ain2.txt","r",stdin);freopen("aout.txt","w",stdout);
cin>>n>>m;
multiset<int > se;
rep(i,1,n)
{
cin>>a[i];
se.insert(a[i]);
}
rep(i,1,m)
{
int x,y;
cin>>x>>y;
d[x]++;
d[y]++;
}
if(n==1)
{
cout<<a[1];
exit(0);
}
int ans=0;
rep(i,1,n)
{
if(d[i]>=2)
{
ans=max(ans,a[i]);
}
else
{
v.pb(a[i]);
}
}
if(v.size()>=2)
{
sort(v.begin(),v.end(),cmp);
}
ans=max(ans,min(v[0],v[1]));
cout<<ans;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5672kb
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