結果
問題 | No.9 モンスターのレベル上げ |
ユーザー | Mister |
提出日時 | 2020-08-19 19:54:08 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
CE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,052 bytes |
コンパイル時間 | 603 ms |
コンパイル使用メモリ | 73,016 KB |
最終ジャッジ日時 | 2024-05-20 10:12:41 |
合計ジャッジ時間 | 1,632 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function 'void solve()': main.cpp:26:18: error: 'std::tuple<int, int, int> <structured bindings>' has incomplete type 26 | auto [x, m, i] = heap.top(); | ^~~~~~~~~ In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/vector:64, from main.cpp:3: /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/stl_vector.h: In instantiation of 'std::_Vector_base<_Tp, _Alloc>::~_Vector_base() [with _Tp = std::tuple<int, int, int>; _Alloc = std::allocator<std::tuple<int, int, int> >]': /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/stl_vector.h:526:7: required from 'std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue() [with _Seq = std::vector<std::tuple<int, int, int>, std::allocator<std::tuple<int, int, int> > >; _Requires = void; _Tp = std::tuple<int, int, int>; _Sequence = std::vector<std::tuple<int, int, int>, std::allocator<std::tuple<int, int, int> > >; _Compare = std::greater<std::tuple<int, int, int> >]' main.cpp:22:44: required from here /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/stl_vector.h:367:49: error: invalid use of incomplete type 'class std::tuple<int, int, int>' 367 | _M_impl._M_end_of_storage - _M_impl._M_start); | ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~ In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/stl_algobase.h:64, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/string:50, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/locale_classes.h:40, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/ios_base.h:41, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ios:42, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include
ソースコード
#include <iostream> #include <algorithm> #include <vector> #include <queue> template <class T> using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>; void solve() { int n; std::cin >> n; std::vector<int> xs(n), ys(n); for (auto& x : xs) std::cin >> x; for (auto& y : ys) std::cin >> y; int ans = n; for (int q = 0; q < n; ++q) { auto nxs = xs; std::vector<int> match(n, 0); MinHeap<std::tuple<int, int, int>> heap; for (int i = 0; i < n; ++i) heap.emplace(nxs[i], match[i], i); for (auto y : ys) { auto [x, m, i] = heap.top(); heap.pop(); nxs[i] += y / 2; ++match[i]; heap.emplace(nxs[i], match[i], i); } ans = std::min(ans, *std::max_element(match.begin(), match.end())); std::rotate(ys.begin(), ys.begin() + 1, ys.end()); } std::cout << ans << "\n"; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); solve(); return 0; }