結果
問題 |
No.2182 KODOKU Stone
|
ユーザー |
![]() |
提出日時 | 2022-12-15 18:10:03 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,470 bytes |
コンパイル時間 | 2,851 ms |
コンパイル使用メモリ | 207,712 KB |
最終ジャッジ日時 | 2025-02-09 13:57:49 |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 3 |
other | AC * 20 WA * 16 RE * 1 |
ソースコード
#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; }