algo

This documentation is automatically generated by competitive-verifier/competitive-verifier

View the Project on GitHub kuhaku-space/algo

:heavy_check_mark: test/aoj/challenge/2208.test.cpp

Depends on

Code

// competitive-verifier: PROBLEM https://onlinejudge.u-aizu.ac.jp/problems/2208
#include <iostream>
#include <numeric>
#include <vector>
#include "heap/interval_heap.hpp"

int main(void) {
    while (true) {
        int n;
        std::cin >> n;
        if (!n) break;
        std::vector<int> a(n), b(n);
        for (int &e : a) std::cin >> e;
        for (int &e : b) std::cin >> e;
        if (std::accumulate(a.begin(), a.end(), 0l) != std::accumulate(b.begin(), b.end(), 0l)) {
            std::cout << "No\n";
            continue;
        }
        int h_min = 0, h_max = n, w_min = 0, w_max = n;
        interval_heap<int> hx, hy;
        for (int e : a) hx.emplace(e);
        for (int e : b) hy.emplace(e);
        bool loop = true;
        while (loop) {
            loop = false;
            if (!hx.empty()) {
                if (hx.get_min() == h_min) {
                    hx.pop_min();
                    --w_max;
                    loop = true;
                } else if (hx.get_max() == h_max) {
                    hx.pop_max();
                    ++w_min;
                    loop = true;
                }
            }
            if (!hy.empty()) {
                if (hy.get_min() == w_min) {
                    hy.pop_min();
                    --h_max;
                    loop = true;
                } else if (hy.get_max() == w_max) {
                    hy.pop_max();
                    ++h_min;
                    loop = true;
                }
            }
        }
        std::cout << (hx.empty() && hy.empty() ? "Yes" : "No") << '\n';
    }

    return 0;
}
Traceback (most recent call last):
  File "/home/runner/.local/lib/python3.12/site-packages/competitive_verifier/oj/resolver.py", line 291, in resolve
    bundled_code = language.bundle(path, basedir=basedir)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/.local/lib/python3.12/site-packages/competitive_verifier/oj/verify/languages/cplusplus.py", line 242, in bundle
    bundler.update(path)
  File "/home/runner/.local/lib/python3.12/site-packages/competitive_verifier/oj/verify/languages/cplusplus_bundle.py", line 479, in update
    self._resolve(pathlib.Path(included), included_from=path)
  File "/home/runner/.local/lib/python3.12/site-packages/competitive_verifier/oj/verify/languages/cplusplus_bundle.py", line 286, in _resolve
    raise BundleErrorAt(path, -1, "no such header")
competitive_verifier.oj.verify.languages.cplusplus_bundle.BundleErrorAt: heap/interval_heap.hpp: line -1: no such header

Test cases

Env Name Status Elapsed Memory
g++ judge_data :heavy_check_mark: AC 12 ms 4 MB
Back to top page