Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
48189 小号 【AB-1】游戏 C++ 运行超时 50 1000 MS 260 KB 1283 2022-04-10 15:51:23

Tests(5/10):


#include <bits/stdc++.h> using namespace std; int n; vector<int> a; namespace kkk { int dfs(int cs) { if (cs == n) return a.front(); int ans = (cs & 1 ? -1 : 0x3f3f3f3f), scz; vector<int>::iterator it = a.begin(), it2 = it, sc, ls; ++it2; for (; it2 != a.end(); ++it, ++it2) { if (cs & 1) { ((*it > *it2) ? (sc = it, scz = *it) : (sc = it2, scz = *it2)); ls = sc; a.erase(sc); ans = max(ans, dfs(cs + 1)); a.insert(ls, scz); } else { ((*it < *it2) ? (sc = it, scz = *it) : (sc = it2, scz = *it2)); ls = sc; a.erase(sc); ans = min(ans, dfs(cs + 1)); a.insert(ls, scz); } } return ans; } void kkk() { cout << dfs(1) << endl; } } void solve() { scanf("%d", &n); bool all0 = true, all01 = true; for (int x, i = 1; i <= n; ++i) { scanf("%d", &x); a.push_back(x); if (x != 0) all0 = false; if (x != 0 && x != 1) all01 = false; } if (all0) cout << 0 << endl; if (all01) cout << 1 << endl; else kkk::kkk(); } int main() { //freopen("game.in", "r", stdin); //freopen("game.out", "w", stdout); solve(); return 0; }


测评信息: