QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#841571#9623. 合成大西瓜1903331632WA 1ms5668kbC++231.0kb2025-01-03 20:33:532025-01-03 20:33:53

Judging History

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

  • [2025-01-03 20:33:53]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5668kb
  • [2025-01-03 20:33:53]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e6 + 10;
int a[N];
int de[N];
void solve()
{
    int n, m;
    cin >> n >> m;
    int maxi = -1e18;
    priority_queue<int> q;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i < m; i++)
    {
        int u, v;
        cin >> u >> v;
        de[u]++;
        de[v]++;
    }
    if (n == 1)
    {
        cout << a[1] << endl;
        return;
    }
    for (int i = 1; i <= n; i++)
    {
        if (de[i] == 1)
        {
            q.push(-a[i]);
            if (q.size() > 2)
                q.pop();
        }
        else
        {
            maxi = max(maxi, a[i]);
        }
    }
    if (q.size())
    {
        maxi = max(maxi, -q.top());
        q.pop();
        maxi = max(maxi, -q.top());
    }
    cout << maxi << "\n";
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;
    while (t--)
        solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 5668kb

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:

7

result:

wrong answer 1st lines differ - expected: '6', found: '7'