Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* [A][M][C][B][N] / [K][R][I][P][6][8] */
- #include <bits/stdc++.h>
- #pragma warning(disable : 4996 4267 4068)
- using namespace std;
- template<typename type>
- using matrix = vector<vector<type>>;
- typedef long long ll;
- const char sp = ' ', nl = '\n';
- const int MOD = 1000000007;
- void solve() {
- int n, m;
- cin >> n;
- vector<int> v(n);
- for (int i = 0; i < n; ++i) cin >> v[i];
- cin >> m;
- vector<int> w(m);
- for (int i = 0; i < m; ++i) cin >> w[i];
- int i(0), j(0);
- for (i = 0; i < n && j < m; ++i) {
- if (!w[j]) ++j;
- w[j] -= v[i];
- if (!w[j]) ++j;
- }
- bool ok(i == n);
- for (int k = 0; k < m; ++k)
- ok &= w[k] == 0;
- cout << ok << nl;
- }
- int main() {
- ios::sync_with_stdio(NULL);
- cin.tie(nullptr), cout.tie(nullptr);
- //(void)!freopen("nrlipsa2.in", "r", stdin);
- //(void)!freopen("nrlipsa2.out", "w", stdout);
- int t;
- cin >> t;
- while (t--) {
- solve();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment