QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#747727 | #9623. 合成大西瓜 | snow_miku# | RE | 0ms | 3844kb | C++20 | 795b | 2024-11-14 18:01:56 | 2024-11-14 18:01:57 |
Judging History
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