QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#772219 | #9623. 合成大西瓜 | candy34# | RE | 1ms | 5860kb | C++20 | 879b | 2024-11-22 17:36:17 | 2024-11-22 17:36:17 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 2e18;
const int MOD = 998244353;
const int N = 3e5+10;
const double eps = 1e-8;
int t,m,n,k;
int d[N];
int arr[N];
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin>>n>>m;
for(int i=1;i<=n;i++){
cin>>arr[i];
}
int ans = 0;
int u,v;
for(int i=1;i<=m;i++){
cin>>u>>v;
d[u]++;
d[v]++;
}
if(n==1){
cout<<arr[1]<<"\n";
return 0;
}
vector<int> key;
for(int i=1;i<=n;i++){
if(d[i]==1){
key.push_back(arr[i]);
}else{
ans = max(ans,arr[i]);
}
}
sort(key.begin(),key.end());
int tmp = min(key[key.size()-1],key[key.size()-2]);
ans = max(ans,tmp);
cout<<ans<<"\n";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5860kb
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