제출 #348947

#제출 시각UTC-0아이디문제언어결과실행 시간메모리
3489472021-01-16 06:50:528e7은행 (IZhO14_bank)C++14
100 / 100
358 ms98924 KiB
//Challenge: Accepted
#include <iostream>
#include <algorithm>
#include <utility>
#include <set>
#define maxn 20
#define pii pair<int, int>
#define ff first
#define ss second
using namespace std;
set<pii> dp[1<<maxn];
int a[maxn], b[maxn];
int main() {
int n, m;
cin >> n >> m;
for (int i = 0;i < n;i++) cin >> a[i];
for (int j = 0;j < m;j++) cin >> b[j];
dp[0].insert(make_pair(0, 0));
int poss = 0;
for (int i = 1;i < (1<<m);i++) {
for (int j = 0;j < m;j++) {
if (i & (1<<j)) {
for (auto v: dp[i - (1<<j)]) {
if (v.ss + b[j] == a[v.ff]) {
dp[i].insert(make_pair(v.ff + 1, 0));
} else if (v.ss + b[j] < a[v.ff]) {
dp[i].insert(make_pair(v.ff, v.ss + b[j]));
}
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...