Submission #988244

# Submission time Handle Problem Language Result Execution time Memory
988244 2024-05-24T11:06:24 Z Tsagana Bank (IZhO14_bank) C++14
0 / 100
1000 ms 596 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, vector<int> a, vector<int> b) {
	if (l >= b.size()) {
		for (int i = 0; i < a.size(); i++)
		if (a[i]) return 0; return 1;
	}

	int ok = 0;
	for (int i = 0; i < a.size(); i++) {
		//WHAT IF GIVE b[l] TO a[i] ???
		if (a[i]) ok = 1;
		if (b[l] && b[l] > a[i]) continue ;

		a[i] -= b[l];
		if (rep(l + 1, a, b)) return 1;
		a[i] += b[l];
	}
	return (ok ? 0 : 1);
}
 
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, b) ? "YES" : "NO");
}
signed main() {IOS solve(); return 0;}

Compilation message

bank.cpp: In function 'bool rep(long long int, std::vector<long long int>, std::vector<long long int>)':
bank.cpp:17: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]
   17 |  if (l >= b.size()) {
      |      ~~^~~~~~~~~~~
bank.cpp:18:21: 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 |   for (int i = 0; i < a.size(); i++)
      |                   ~~^~~~~~~~~~
bank.cpp:19:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   19 |   if (a[i]) return 0; return 1;
      |   ^~
bank.cpp:19:23: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   19 |   if (a[i]) return 0; return 1;
      |                       ^~~~~~
bank.cpp:18:3: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   18 |   for (int i = 0; i < a.size(); i++)
      |   ^~~
bank.cpp:19:23: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   19 |   if (a[i]) return 0; return 1;
      |                       ^~~~~~
bank.cpp:23: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]
   23 |  for (int i = 0; i < a.size(); i++) {
      |                  ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Incorrect 1 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1032 ms 596 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -