제출 #521727

#제출 시각아이디문제언어결과실행 시간메모리
521727KalashnikovBank (IZhO14_bank)C++17
19 / 100
55 ms324 KiB
#include <bits/stdc++.h>
 
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define all(a) a.begin() , a.end()
#define F first
#define S second
 
using namespace std;
using ll = long long;
 
const int N = 2e5+5 , inf = 2e9 + 7;
const ll INF = 1e18 ,   mod = 1e9+7 , P = 6547;

int a[N] , b[N];


void solve(int tc) {
	int n , m;
	cin >> n >> m;
	for(int i = 1; i <= n; i ++) {
		cin >> a[i];
	}
	for(int i = 1; i <= m; i ++) {
		cin >> b[i];
	}
	for(int i = 1; i <= n; i ++) {
		int ok = 0;
		for(int mask = 0; mask < (1 << m); mask ++) {
			int sum = 0;
			for(int j = 1; j <= m; j ++) {
				if(mask & (1 << j-1)) {
					sum += b[j];
				}
			}
			if(sum == a[i]) {
				for(int j = 1; j <= m; j ++) {
					if(mask & (1 << j-1)) {
						b[j] = 0;
					}
				}
				ok = 1;
				break;
			}
		}
		if(!ok) {
			cout << "NO";
			return;
		}
	}
	cout << "YES";
}
/*
*/
main() {
    ios;
    int tt = 1 , tc = 0;
    // cin >> tt;
    while(tt --) {
        solve(++tc);
    }
    return 0;
}

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

bank.cpp: In function 'void solve(int)':
bank.cpp:32:22: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   32 |     if(mask & (1 << j-1)) {
      |                     ~^~
bank.cpp:38:23: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   38 |      if(mask & (1 << j-1)) {
      |                      ~^~
bank.cpp: At global scope:
bank.cpp:55:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   55 | main() {
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...