QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#741143 | #9623. 合成大西瓜 | ticking_away# | WA | 0ms | 3768kb | C++20 | 1.7kb | 2024-11-13 13:34:09 | 2024-11-13 13:34:09 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ui = unsigned int;
using ull = unsigned long long;
using ll = long long;
#define endl '\n'
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int maxn = 2e5 + 10;
const int mod = 1000000007;
#define inl inline
#define fr(i, a, b) for (int i = a; i <= b; i++)
#define ford(i, a, b) for (int i = a; i >= b; i--)
#define forall(i, a) for (auto &i : a)
/**
____ ___ _____
/ ___| _ _ / _ \___ /
\___ \| | | | | | ||_ \
___) | |_| | |_| |__) |
|____/ \__, |\___/____/
|___/
*/
istream &operator>>(istream &in, vector<int> &v)
{
for (auto &i : v)
in >> i;
return in;
}
ostream &operator<<(ostream &out, vector<int> &v)
{
for (auto &i : v)
out << i << " ";
return out;
}
bool _output = 0;
void solve()
{
int n, m;
cin >> n >> m;
vector<int> a(n + 1);
fr(i, 1, n) cin >> a[i];
sort(a.begin() + 1, a.end(), greater<int>());
int mx = *max_element(a.begin() + 1, a.end());
unordered_map<int, int> mp;
fr(i, 1, n)
{
mp[a[i]]++;
}
vector<int> d(n + 1);
fr(i, 1, m)
{
int u, v;
cin >> u >> v;
d[u]++;
d[v]++;
}
bool suc = 0;
fr(i, 1, n)
{
if (a[i] == mx && d[i] > 1)
{
suc = 1;
}
}
if (suc)
{
cout << a[1] << endl;
}
else
cout << a[2] << endl;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int _ = 1;
if (_output)
cin >> _;
while (_--)
solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3744kb
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: 0
Accepted
time: 0ms
memory: 3596kb
input:
5 7 1 5 3 1 4 3 5 1 3 5 1 1 4 5 4 2 4 3 2
output:
5
result:
ok single line: '5'
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3768kb
input:
7 7 2 4 2 3 3 6 7 5 1 2 6 5 3 4 6 1 6 1 2 2 7
output:
7
result:
wrong answer 1st lines differ - expected: '6', found: '7'