제출 #1098129

#제출 시각아이디문제언어결과실행 시간메모리
1098129vjudge1은행 (IZhO14_bank)C++17
71 / 100
1051 ms67912 KiB
//order_of_key(k): Number of items strictly smaller than k .
//find_by_order(k): K-th element in a set (counting from zero).

//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define file(s) if(fopen(s".in","r")) freopen(s".in","r",stdin);freopen(s".out","w",stdout)
#define all(x) (x).begin(), (x).end()
#define len(x) (int)x.size()
#define tm (tl + tr >> 1)
#define ls v << 1, tl, tm
#define rs v << 1 | 1, tm + 1, tr
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define elif else if
#define F first
#define S second
//#define int long long

using namespace std;
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef unsigned long long ull;
typedef long long ll;
typedef double db;
typedef long double ld;

const int MOD = 1e9 + 7;
const int N = 2e5 + 7;
const int P = 911;
const ll INF = 1e18;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int rnd() {
	int x = rand() << 15;
	return x ^ rand();
}

int a[1001], b[1001];	
int cnt[N * 10];

void GazizMadi() {
	int n, m;
	bool ans = 0;
	cin >> n >> m;
	set <int> s;
	s.insert(0);
	for (int i = 1; i <= n; i++) cin >> a[i];
	for (int i = 0; i < m; i++) cin >> b[i];
	for (int i = 1; i <= n; i++) {
		vector <int> nw;
		for (int mask = 1; mask < (1 << m); mask++) {
			int sum = 0;
			for (int j = 0; j < m; j++) sum += b[j] * ((mask >> j) & 1);
			if (sum != a[i]) continue;
//			cout << sum << '\n';
			for (int it: s) if (!(it & mask)) nw.pb((it | mask));
				 
		}
		s.clear();
		for (int it: nw) s.insert(it);
	}
	cout << (len(s) ? "YES" : "NO");
}

const bool Cases = 0;

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	srand(time(0));
	int TT = 1;
	if (Cases) cin >> TT;
	for (int i = 1; i <= TT; i++) {
		//cout << "Case " << i << ": ";
		GazizMadi();
	}
}

컴파일 시 표준 에러 (stderr) 메시지

bank.cpp: In function 'void GazizMadi()':
bank.cpp:64:7: warning: unused variable 'ans' [-Wunused-variable]
   64 |  bool ans = 0;
      |       ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...