Submission #825177

# Submission time Handle Problem Language Result Execution time Memory
825177 2023-08-14T15:05:50 Z tpd2k Bank (IZhO14_bank) C++17
19 / 100
1 ms 340 KB
// teddybear's code
// the one who loves NBP
// noe the second
// goal: 0 / 8
// get medal in APIO (like TKN)
//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt")

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

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

#define FOR(i,n) for (int i = 0; i<n; i++)
using ll = long long;
using ull = unsigned long long;
ll n,m,t;
ll cnt = 0;
const int maxn = 1e5;
const ll mod = 1e9 + 7;
#define Y "YES"
#define N "NO"
ll a[2 * maxn + 5];
ll b[2 * maxn + 5];
bool visited[1005][1005];
int dist[1005][1005];
int w,h;
int fx[4] = {-1, 1, 0, 0};
int fy[4] = {0, 0, -1, 1};
queue <pair<int,int>> q;
ll dis[2 * maxn + 5];
pair<ll,ll> p[2 * maxn + 5];

ll dp[2 * maxn + 5];

vector <ll> bactrac(ll l, ll r)
{
	ll len = r - l + 1;
	vector <ll> ans;
	for (ll i = 0; i<(1<<len); i++)
	{
		ll res = 0;
		for (ll j = 0; j<len; j++)
		{
			if (i & (1 << j))
			{
				res += b[l + j];
			}
		}
		ans.push_back(res);
	}
	return ans;
}

void sub1()
{
	vector <ll> le = bactrac(1,m/2);
	vector <ll> ri = bactrac(m/2+1,m);
	sort(le.begin(), le.end());
	sort(ri.begin(), ri.end());
	for (ll j : le)
	{
		ll curr = lower_bound(ri.begin(), ri.end(), a[1] - j) - ri.begin();
		//cout << "! " << j << ' ' << ri[curr] << '\n';
		if (curr < ri.size() && (j + ri[curr]) == a[1])
		{
			cout << "YES";
			return;
		}
	}
	cout << "NO";
}

void solve()
{
	cin >> n >> m;
	for (int i = 1; i<=n; i++)
	{
		cin >> a[i];	
	}
	for (int i = 1; i<=m; i++)
	{
		cin >> b[i];
	}
	if (n == 1)
	{
		sub1();
	}
	
}

void init()
{
 	int te = 1; //cin >> te;
 	while (te--)
 	{
 	 	  solve();
 	}
}

void preprocess()
{

}


int main()
{
 	ios_base::sync_with_stdio(false);
 	cin.tie(NULL);
    //cin.tie(0); cout.tie(0);
    //freopen(".inp", "r", stdin);
    //freopen(".out", "w", stdout);
 	init();
 	preprocess();
 	//solve();
 	return 0;
}

Compilation message

bank.cpp: In function 'void sub1()':
bank.cpp:67:12: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |   if (curr < ri.size() && (j + ri[curr]) == a[1])
      |       ~~~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 276 KB Output is correct
3 Correct 0 ms 336 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 336 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 276 KB Output is correct
3 Correct 0 ms 336 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 336 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Incorrect 0 ms 212 KB Output isn't correct
11 Halted 0 ms 0 KB -