QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#788301 | #9623. 合成大西瓜 | masttf# | WA | 0ms | 3588kb | C++20 | 1.4kb | 2024-11-27 16:28:42 | 2024-11-27 16:28:45 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
#define dbg(x...) \
do { \
cout << #x << " -> "; \
err(x); \
} while (0)
void err() {
cout << endl << endl;
}
template<class T, class... Ts>
void err(T arg, Ts ... args) {
cout << fixed << setprecision(10) << arg << ' ';
err(args...);
}
void solve(){
int n, m; cin >> n >> m;
vector<vector<int>> g(n + 1);
vector<int> val(n + 1);
for(int i = 1; i <= n; i++) cin >> val[i];
for(int i = 1; i <= m; i++){
int u, v; cin >> u >> v;
g[u].push_back(v);
g[v].push_back(u);
}
if(n == 1){
cout << val[1] << '\n';
return ;
}
for(int i = 1; i <= n; i++){
sort(g[i].begin(), g[i].end(), [&](int x, int y) -> bool{
return val[x] > val[y];
});
}
int ans = 0;
for(int i = 1; i <= n; i++){
if(g[i].size() >= 2){
ans = max(ans, val[i]);
}
}
// dbg(ans);
vector<int> res;
for(int i = 1; i <= n; i++){
if(g[i].size() == 1){
res.push_back(val[i]);
}
}
sort(res.begin(), res.end(), greater<>());
if(res.size() >= 2)ans = min(ans, res[1]);
cout << ans << '\n';
return ;
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
int t = 1; // cin >> t;
while(t--)solve();
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3588kb
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:
1
result:
wrong answer 1st lines differ - expected: '6', found: '1'