結果
問題 | No.2223 Merged Med |
ユーザー | stoq |
提出日時 | 2022-01-27 15:04:26 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,044 bytes |
コンパイル時間 | 2,213 ms |
コンパイル使用メモリ | 206,440 KB |
実行使用メモリ | 8,760 KB |
最終ジャッジ日時 | 2023-09-26 17:54:42 |
合計ジャッジ時間 | 11,422 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,380 KB |
testcase_01 | AC | 2 ms
4,384 KB |
testcase_02 | AC | 2 ms
4,380 KB |
testcase_03 | AC | 1 ms
4,380 KB |
testcase_04 | AC | 2 ms
4,380 KB |
testcase_05 | AC | 3 ms
4,380 KB |
testcase_06 | AC | 1 ms
4,380 KB |
testcase_07 | AC | 3 ms
4,376 KB |
testcase_08 | AC | 2 ms
4,380 KB |
testcase_09 | AC | 3 ms
4,384 KB |
testcase_10 | AC | 7 ms
4,380 KB |
testcase_11 | AC | 1 ms
4,384 KB |
testcase_12 | AC | 3 ms
4,380 KB |
testcase_13 | TLE | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
ソースコード
// 愚直解 #include <bits/stdc++.h> using namespace std; #define REP(i, m, n) for (int i = m; i < (int)(n); ++i) #define rep(i, n) REP(i, 0, n) template <typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } int mid(vector<int> a) { sort(begin(a), end(a)); int k = a.size(); return a[k / 2]; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n, q; cin >> n >> q; vector<int> a(n); rep(i, n) cin >> a[i], a[i]--; vector<int> l(q), r(q); rep(i, q) cin >> l[i] >> r[i], l[i]--; auto solve_i = [&](int L, int R) { int Min = int(1e9); REP(l, L, R) { REP(r, l + 1, R + 1) { vector<int> b(a.begin() + l, a.begin() + r); vector<int> c; for (int i = L; i < R;) { if (i < l or i >= r) c.push_back(a[i]), i++; else c.push_back(mid(b)), i = r; } chmin(Min, mid(c)); } } return Min; }; rep(i, q) cout << solve_i(l[i], r[i]) + 1 << "\n"; }