제출 #1108516

#제출 시각아이디문제언어결과실행 시간메모리
1108516vjudge1은행 (IZhO14_bank)C++17
19 / 100
142 ms1484 KiB
//gm  --- akezhon
#include <bits/stdc++.h>
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define pb push_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define tm (tl+tr)/2
#define TL v+v, tl, tm
#define TR v+v+1, tm+1, tr
#define DA l <= tl && tr <= r
#define NE r < tl || tr < l
#define double long double
#define int long long

using namespace std;

const int N=2e5+7;
const int N2=1e6+7;
const int mod=1e9+7;
const int inf=2e18;
const double eps=1e-9;

int n, m;
int a[21], b[21], p[21];
bool dp[2][2100000];

void AlemAmenov(){
	cin >> n >> m;
	for(int i=1; i <= n; i++){
		cin >> a[i];
		p[i] = p[i-1]+a[i];
	}
	for(int i=1; i <= m; i++){
		cin >> b[i];
	}
	bool ok=0;
	for(int i=1; i <= n; i++){
		for(int mask=1; mask < (1<<m); mask++){
			int sum=0;
			for(int j=1; j <= m; j++){
				if(mask&(1<<(j-1)))sum += b[j];
			}
			if(sum == p[i] && (dp[i&1^1][mask] || i==1))dp[i&1][mask]=1;
			else{
				for(int j=1; j <= m; j++){
					if((mask&(1<<(j-1))) && dp[i&1][mask^(1<<(j-1))]){
						dp[i&1][mask]=1;
						break;
					}
				}
			}
			if(i==n && dp[i&1][mask])ok=1;
		}
	}
	cout << (ok ? "YES" : "NO");
}
signed main(){

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int RealName=1;
	// cin >> RealName;

	while(RealName--)
		AlemAmenov();
	
return 0;
}	

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

bank.cpp: In function 'void AlemAmenov()':
bank.cpp:46:27: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   46 |    if(sum == p[i] && (dp[i&1^1][mask] || i==1))dp[i&1][mask]=1;
      |                          ~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...