QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#768989 | #9623. 合成大西瓜 | lilmx | WA | 0ms | 3508kb | C++20 | 761b | 2024-11-21 15:38:21 | 2024-11-21 15:38:21 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int N=1e5+10;
ll a[N];
ll d[N];
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int n,m; cin>>n>>m;
for(int i=1;i<=n;i++) cin>>a[i];
for(int i=1;i<=m;i++){
int u,v; cin>>u>>v;
d[u]++;
d[v]++;
}
if(n==1){
cout<<a[1]<<"\n";
return 0;
}
ll mx=-1,ans1=-1,ans2=-1;
for(int i=1;i<=n;i++){
if(d[i]==1){
if(a[i]>ans1){
ans2=ans1;
ans1=a[i];
}
else ans2=max(ans2,a[i]);
}
else mx=max(mx,a[i]);
}
if(ans2==-1) cout<<mx;
else if(mx=-1) cout<<ans2;
else cout<<max(mx,ans2);
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3508kb
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:
1
result:
wrong answer 1st lines differ - expected: '6', found: '1'