QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#841571 | #9623. 合成大西瓜 | 1903331632 | WA | 1ms | 5668kb | C++23 | 1.0kb | 2025-01-03 20:33:53 | 2025-01-03 20:33:53 |
Judging History
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'