QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#758747 | #9623. 合成大西瓜 | 5720226849# | WA | 1ms | 5592kb | C++14 | 1.9kb | 2024-11-17 19:33:57 | 2024-11-17 19:33:59 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define Yes cout << "Yes\n"
#define No cout << "No\n"
#define YES cout << "YES\n"
#define NO cout << "NO\n"
#define ls u << 1
#define rs u << 1 | 1
#define all(x) x.begin(),x.end()
#define i128 __int128
#define int long long
#define Genshin_Impact return
#define Starts 0
#define _o_o_ return
#define o_o_o return
inline int gcd(int a, int b) {return b > 0 ? gcd(b, a % b) : a;}
inline int lowbit(int x) {return x & (-x);}
int qmi(int a, int b, int mod){int res = 1;while(b) {if(b & 1) res = res * a % mod;a = a * a % mod;b >>= 1;}return res;}
// inline i128 read(){i128 x = 0, f = 1;char ch = getchar();while(ch < '0' || ch > '9'){if(ch == '-')f = -1;ch = getchar();}while(ch >= '0' && ch <= '9'){x = x * 10 + ch - '0';ch = getchar();}return x * f;}
// inline void print(i128 x){if(x < 0){putchar('-');x = -x;}if(x > 9)print(x / 10);putchar(x % 10 + '0');}
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<double, PII> PIII;
const int N = 5e5 + 10, logn = 21, inf = 1e18, mod = 998244353, M = 2e6 + 10;
const int P = 131;
#define ull unsigned long long
int n, m;
vector<int>v;
int a[N], d[N], mx = 0;
void solve()
{
// 选一个不是叶子的最大值
// 或者次大叶子
cin >> n >> m;
for(int i = 1; i <= n; i ++) cin >> a[i];
for(int i = 1; i <= m; i ++) {
int u, v; cin >> u >> v;
d[u] ++, d[v] ++;
}
if(n == 1) {
cout << a[1] << '\n';
return;
}
for(int i = 1; i <= n; i ++)
if(d[i] == 1) v.push_back(a[i]);
else mx = max(mx, a[i]);
sort(v.begin(), v.end());
cout << max(mx, v[1]) << '\n';
}
signed main()
{
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int t = 1;
// cin >> t;
while (t--)
solve();
Genshin_Impact Starts;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 5592kb
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'