跳到正文

题解

题解:CF2061D Kevin and Numbers

zysqhy约 1 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2026年3月21日
篇幅
约 1 分钟
题目
CF2061D

版本

  1. v1当前

#include <bits/stdc++.h> using namespace std;

int main() { int t; cin >> t; while (t—) { int n, m; cin >> n >> m; multiset<int> a, b; for (int i = 0; i < n; i++) { int x; cin >> x; a.insert(x); } for (int i = 0; i < m; i++) { int x; cin >> x; b.insert(-x); } while (!b.empty() && b.size() <= a.size()) { auto x = -(*b.begin()); b.erase(b.begin()); if (a.find(x) != a.end()) { a.extract(x); } else { int y = x / 2, z = x - y; b.insert(-y); b.insert(-z); } } cout << (a == b ? “Yes” : “No”) << endl; } return 0; }

原文