QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#768989#9623. 合成大西瓜lilmxWA 0ms3508kbC++20761b2024-11-21 15:38:212024-11-21 15:38:21

Judging History

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

  • [2024-11-21 15:38:21]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3508kb
  • [2024-11-21 15:38:21]
  • 提交

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);
}

详细

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'