QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#811350 | #9623. 合成大西瓜 | TosakaUCW# | WA | 0ms | 3736kb | C++20 | 2.1kb | 2024-12-12 18:20:27 | 2024-12-12 18:20:28 |
Judging History
answer
#include <bits/stdc++.h>
using i64 = long long;
#define int i64
#define pb push_back
#define ep emplace
#define eb emplace_back
using std::cerr;
// using namespace std::views;
// using namespace std::ranges;
using std::max, std::min, std::swap, std::array;
using std::cin, std::cout, std::string, std::vector;
using std::ostream;
template <class T1, class T2> ostream &operator<<(ostream &os, const std::pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << '\n'; }
using pii = std::pair<int, int>;
#define fi first
#define se second
double eps = 1e-7;
const int inf = 1e18;
void solve() {
int n; cin >> n;
int m; cin >> m;
vector<int> a(n);
for (auto &x : a) cin >> x;
vector<int> ind(n);
vector<vector<int>> g(n);
for (int i = 0; i < m; i++) {
int u, v;
cin >> u >> v;
u--, v--;
g[u].eb(v), g[v].eb(u);
ind[u]++, ind[v]++;
}
vector<int> vis(n);
// for (int i = 0; i < n; i++) {
// if (ind[i] != 1 or vis[i]) continue;
// int mx = -1;
// int u = g[i][0];
// for (int v : g[u]) {
// if (v == i) continue;
// if (mx == -1 or a[v] > a[mx]) mx = v;
// }
// a[u] = max(a[u], min(a[mx], a[i]));
// vis[i] = vis[mx] = 1;
// }
int ans = 0, res = inf;
for (int i = 0; i < n; i++) {
if (ind[i] % 2 == 1) res = min(res, a[i]);
else ans = max(ans, a[i]);
}
if (res != inf) ans = max(ans, res);
cout << ans;
}
signed main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
// int T; cin >> T;
// for (; T--; solve());
solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3608kb
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: 3736kb
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: 3604kb
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:
3
result:
wrong answer 1st lines differ - expected: '6', found: '3'