結果
問題 | No.2182 KODOKU Stone |
ユーザー | MasKoaTS |
提出日時 | 2022-12-15 18:10:03 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,470 bytes |
コンパイル時間 | 2,263 ms |
コンパイル使用メモリ | 207,644 KB |
実行使用メモリ | 47,368 KB |
最終ジャッジ日時 | 2024-04-26 21:09:55 |
合計ジャッジ時間 | 6,942 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | AC | 2 ms
5,376 KB |
testcase_11 | AC | 250 ms
12,548 KB |
testcase_12 | RE | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | AC | 395 ms
14,596 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | AC | 116 ms
10,876 KB |
testcase_19 | AC | 73 ms
6,656 KB |
testcase_20 | AC | 105 ms
9,144 KB |
testcase_21 | AC | 47 ms
5,376 KB |
testcase_22 | WA | - |
testcase_23 | AC | 64 ms
5,784 KB |
testcase_24 | AC | 54 ms
5,376 KB |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | AC | 114 ms
10,172 KB |
testcase_30 | AC | 128 ms
11,212 KB |
testcase_31 | AC | 89 ms
8,620 KB |
testcase_32 | AC | 90 ms
8,216 KB |
testcase_33 | AC | 105 ms
9,656 KB |
testcase_34 | AC | 55 ms
5,376 KB |
testcase_35 | AC | 107 ms
9,648 KB |
testcase_36 | AC | 26 ms
5,376 KB |
testcase_37 | AC | 127 ms
10,936 KB |
testcase_38 | AC | 2 ms
5,376 KB |
testcase_39 | WA | - |
ソースコード
#include <bits/stdc++.h> #define all(x) x.begin(), x.end() #define lb(v, a) (int)(lower_bound(all(v), a) - v.begin()) using namespace std; template <class T> using V = vector<T>; bool check(int& N, V<int>& K, V<V<int> >& A, int& m) { V<int> P = {}; int q_max = 0; for (int i = 0; i < N; ++i) { int s = A[i].size() - lb(A[i], m); if (s < A[i].size()) { P.push_back(s); } else if (q_max > s) { q_max = s; } } sort(all(P)); multiset<int> mst = {}; for (int i = N - 1; i >= P.size(); --i) { mst.insert(K[i]); } if (q_max >= *mst.begin()) { return true; } for (int i = P.size() - 1; i >= 0; --i) { int u = min(*mst.begin(), K[i]); if (P[i] >= u) { return true; } else if (P[i] < u - 1) { return false; } else if (q_max >= K[i]) { return true; } mst.erase(mst.begin()); mst.insert(K[i]); P.pop_back(); } return true; } int main(void) { int N; cin >> N; V<int> K(N); for (int i = 0; i < N; ++i) { cin >> K[i]; } V<int> T(N); V<V<int> > A(N, V<int>({})); V<int> st = {}; for (int i = 0; i < N; ++i) { cin >> T[i]; for (int j = 0; j < T[i]; ++j) { int a; cin >> a; A[i].push_back(a); st.push_back(a); } sort(all(A[i])); } st.erase(unique(all(st)), st.end()); sort(all(st)); int ok = 0, ng = st.size(); while (ng - ok > 1) { int t = (ok + ng) >> 1; if (check(N, K, A, st[t])) { ok = t; } else { ng = t; } } int ans = st[ok]; cout << ans << endl; return 0; }