Submission #988237

# Submission time Handle Problem Language Result Execution time Memory
988237 2024-05-24T10:47:19 Z Tsagana Bank (IZhO14_bank) C++14
0 / 100
177 ms 81984 KB
#include<bits/stdc++.h>
 
#define IOS ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define all(x) x.begin(), x.end()
#define int long long
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pp pop_back
#define F first
#define S second
 
using namespace std;
 
bool rep(int l, int x, vector<int> a, vector<int> b) {
	if (!x) {l++; if (l < a.size()) x = a[l];}
	if (l >= a.size()) return 1;
	
	for (int i = 0; i < b.size(); i++) {
		if (b[i] > a[l]) continue ;
		
		int k = b[i]; b[i] = 2000;
		if (rep(l, x - k, a, b)) return 1;
		b[i] = k;
	}
	return 0;
}
 
void solve () {
	vector<int> a, b;
	int n, m;  cin >> n >> m;
	a.resize(n); b.resize(m);
	for (int &i: a) cin >> i;
	for (int &i: b) cin >> i;
 
	sort(all(a)); sort(all(b));
	while (!b.empty() && b.back() > a.back()) b.pp();
	
	cout << (rep(0, a[0], a, b) ? "YES" : "NO");
}
signed main() {
	IOS
	#ifndef LOCAL
		freopen("bank.in", "r", stdin);
		freopen("bank.out", "w", stdout);
	#endif
 
	solve();
	return 0;
}

Compilation message

bank.cpp: In function 'bool rep(long long int, long long int, std::vector<long long int>, std::vector<long long int>)':
bank.cpp:17:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |  if (!x) {l++; if (l < a.size()) x = a[l];}
      |                    ~~^~~~~~~~~~
bank.cpp:18:8: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |  if (l >= a.size()) return 1;
      |      ~~^~~~~~~~~~~
bank.cpp:20:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |  for (int i = 0; i < b.size(); i++) {
      |                  ~~^~~~~~~~~~
bank.cpp: In function 'int main()':
bank.cpp:45:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   45 |   freopen("bank.in", "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
bank.cpp:46:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   46 |   freopen("bank.out", "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 177 ms 81984 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 148 ms 81800 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 148 ms 81800 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 177 ms 81984 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -