QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#755502#9623. 合成大西瓜rdcamelotWA 0ms3588kbC++20926b2024-11-16 17:31:042024-11-16 17:31:06

Judging History

你现在查看的是最新测评结果

  • [2024-11-16 17:31:06]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3588kb
  • [2024-11-16 17:31:04]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using i64=long long;
using u64=unsigned long long;
#define ll long long
const int inf=1e9;
const ll inff=1e18;
using i128=__int128;

void solve(){
    int n,m;
    cin>>n>>m;
    vector<int> a(n);
    vector<int> in(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<m;i++){
        int u,v;
        cin>>u>>v;
        u--,v--;
        in[u]++,in[v]++;
    }
    if(n==2 || n==1){
        cout<<*max_element(a.begin(),a.end())<<'\n';
        return;
    }
    int mn=INT_MAX;
    int ans=-1;
    for(int i=0;i<n;i++){
        if(in[i]!=1){
            ans=max(ans,a[i]);
        }else{
            mn=min(mn,a[i]);
        }
    }
    ans=max(ans,mn);
    cout<<ans<<'\n';
}

int main(){
    ios::sync_with_stdio(0);cin.tie(0);
    int t=1;
    // cin>>t; 
    while(t--){
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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
Wrong Answer
time: 0ms
memory: 3552kb

input:

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

output:

2147483647

result:

wrong answer 1st lines differ - expected: '5', found: '2147483647'