QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#747727#9623. 合成大西瓜snow_miku#RE 0ms3844kbC++20795b2024-11-14 18:01:562024-11-14 18:01:57

Judging History

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

  • [2024-11-14 18:01:57]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:3844kb
  • [2024-11-14 18:01:56]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using LL = long long;
const LL mod = 998244353;

void solve()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(n + 1);
    vector<int> d(n + 1);
    for(int i = 1; i <= n; i++){cin >> a[i];}
    for(int i = 1; i <= m; i++){
        int x, y;
        cin >> x >> y;
        d[x]++;
        d[y]++;
    }
    if(m == 0){cout << a[1] << "\n"; return ;}
    priority_queue<int> q1;
    priority_queue<int> q2;
    for(int i = 1; i <= n; i++){
        if(d[i] == 1)q1.push(a[i]);
        if(d[i] > 1)q2.push(a[i]);
    }
    int x = q2.top();
    if(q1.top() >= 2){ q1.pop(); x = max(x, q1.top());}
    cout << x << "\n";
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    solve();
    return 0;
};

詳細信息

Test #1:

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

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

output:


result: