QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#750008 | #9623. 合成大西瓜 | Snowball | WA | 0ms | 6300kb | C++14 | 1.0kb | 2024-11-15 12:03:05 | 2024-11-15 12:03:05 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
// clang-format off
inline int read()
{
int x = 0, f = 1; char ch = getchar();
while(!isdigit(ch)) {if(ch == '-') f = -f; ch = getchar();}
while(isdigit(ch)) {x = x * 10 + ch - '0'; ch = getchar();}
return x * f;
}
// clang-format on
const int N = 100005;
vector<int> edges[N];
int w[N];
int main()
{
int n = read(), m = read();
for (int i = 1; i <= n; i++)
w[i] = read();
for (int i = 1; i <= m; i++)
{
int u = read(), v = read();
edges[u].push_back(v);
edges[v].push_back(u);
}
vector<int> leaves, other;
for (int i = 1; i <= n; i++)
{
if (edges[i].size() == 1)
leaves.push_back(w[i]);
else
other.push_back(w[i]);
}
sort(all(leaves), less<int>());
sort(all(other), less<int>());
if (leaves.size() <= 1)
cout << other[0];
else
cout << leaves[1];
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 6300kb
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'