답안 #91003

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
91003 2018-12-25T14:42:36 Z Nodir_Bobiev 은행 (IZhO14_bank) C++14
44 / 100
1000 ms 708 KB
# include <bits/stdc++.h>

# define ll long long
# define fi first
# define se second

using namespace std;

const ll  INF = 8e18 + 10;
const ll  MOD = 1e9 + 7;
const int N = 1e5 + 10;
const int Z = 5e4 + 10;


int n, m;
int a[30], b[30], c[30];

void rec(int s[30], int ind)
{
	bool t = true;
	
	for(int i = 1; i <= n; i++)
		if(s[i] != a[i])
			t = false;
	
	if(t){
		cout << "YES";
		exit(0);
	}
	
	if(ind == m + 1)return;
	
	for(int i = 1; i <= n; i++)
		if(s[i] + b[ind] > a[i] &&  s[i] != a[i])
			return;
		
	
	for (int i = 1; i <= n + 1; i++){
		if(s[i] + b[ind] <= a[i]){
			s[i] += b[ind];
			rec(s, ind + 1);
			s[i] -= b[ind];
		}
	}
}

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 > m){
		cout << "NO";
		return;	
	}
	sort(b + 1, b + m + 1);
	a[n + 1] = 10000000;
	rec(c, 1);
	cout << "NO";
	return;
}


int main()
{
	int TE = 1;
	ios_base::sync_with_stdio(false);
	//freopen("sort.in", "r", stdin);
	//freopen("sort.out", "w", stdout);
	//cin >> TE;
	
	while(TE --)
		solve();
	
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 468 KB Output is correct
3 Correct 2 ms 468 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Correct 2 ms 580 KB Output is correct
8 Correct 2 ms 644 KB Output is correct
9 Correct 13 ms 644 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 644 KB Output is correct
2 Correct 2 ms 644 KB Output is correct
3 Correct 2 ms 644 KB Output is correct
4 Correct 2 ms 644 KB Output is correct
5 Correct 2 ms 644 KB Output is correct
6 Correct 2 ms 644 KB Output is correct
7 Correct 2 ms 704 KB Output is correct
8 Correct 3 ms 704 KB Output is correct
9 Correct 2 ms 704 KB Output is correct
10 Correct 2 ms 704 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 704 KB Output is correct
2 Correct 6 ms 704 KB Output is correct
3 Correct 4 ms 704 KB Output is correct
4 Correct 2 ms 704 KB Output is correct
5 Correct 2 ms 704 KB Output is correct
6 Correct 2 ms 704 KB Output is correct
7 Correct 164 ms 708 KB Output is correct
8 Correct 22 ms 708 KB Output is correct
9 Correct 7 ms 708 KB Output is correct
10 Correct 7 ms 708 KB Output is correct
11 Execution timed out 1078 ms 708 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 468 KB Output is correct
3 Correct 2 ms 468 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Correct 2 ms 580 KB Output is correct
8 Correct 2 ms 644 KB Output is correct
9 Correct 13 ms 644 KB Output is correct
10 Correct 2 ms 644 KB Output is correct
11 Correct 2 ms 644 KB Output is correct
12 Correct 2 ms 644 KB Output is correct
13 Correct 2 ms 644 KB Output is correct
14 Correct 2 ms 644 KB Output is correct
15 Correct 2 ms 644 KB Output is correct
16 Correct 2 ms 704 KB Output is correct
17 Correct 3 ms 704 KB Output is correct
18 Correct 2 ms 704 KB Output is correct
19 Correct 2 ms 704 KB Output is correct
20 Correct 26 ms 704 KB Output is correct
21 Correct 6 ms 704 KB Output is correct
22 Correct 4 ms 704 KB Output is correct
23 Correct 2 ms 704 KB Output is correct
24 Correct 2 ms 704 KB Output is correct
25 Correct 2 ms 704 KB Output is correct
26 Correct 164 ms 708 KB Output is correct
27 Correct 22 ms 708 KB Output is correct
28 Correct 7 ms 708 KB Output is correct
29 Correct 7 ms 708 KB Output is correct
30 Execution timed out 1078 ms 708 KB Time limit exceeded