Submission #1002806

#TimeUsernameProblemLanguageResultExecution timeMemory
1002806pdaoBank (IZhO14_bank)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#define int long long
#define vi 

using namespace std;

signed main() {
	int ppl, banknote;
	cin >> ppl >> banknote;

	vi ppls(ppl), banknotes(banknote), left(1 << banknote, -1), paid(1 << banknote, -1);
	
	for (int i = 0; i < ppl; i++) cin >> ppls[i];
	for (int i = 0; i < banknote; i++) cin >> banknotes[i];
	
	left[0] = 0;
	paid[0] = 0;

	for (int mask = 0; mask < (1 << banknote); mask++) {
		for (int last = 0; last < banknote; last++) {
			if ((mask & (1 << last)) == 0) continue;

			int prev = mask & ~(1 << last);

			if (paid[prev] != -1) {
				int cur = left[prev] + banknotes[last]; // current ppl
				
				int curm = ppls[paid[prev]]; // target money for current ppl

				if (cur < curm) {
					paid[mask] = paid[prev];
					left[mask] = cur;
				}

				else if (cur == curm) {
					paid[mask] = paid[prev] + 1;
					left[mask] = 0;
				}
			}
		}
		
		if (paid[mask] == ppl) {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
}

Compilation message (stderr)

bank.cpp: In function 'int main()':
bank.cpp:11:5: error: 'ppls' was not declared in this scope; did you mean 'ppl'?
   11 |  vi ppls(ppl), banknotes(banknote), left(1 << banknote, -1), paid(1 << banknote, -1);
      |     ^~~~
      |     ppl
bank.cpp:11:16: error: 'banknotes' was not declared in this scope; did you mean 'banknote'?
   11 |  vi ppls(ppl), banknotes(banknote), left(1 << banknote, -1), paid(1 << banknote, -1);
      |                ^~~~~~~~~
      |                banknote
bank.cpp:11:44: error: invalid initialization of non-const reference of type 'std::ios_base&' from an rvalue of type 'int'
   11 |  vi ppls(ppl), banknotes(banknote), left(1 << banknote, -1), paid(1 << banknote, -1);
      |                                          ~~^~~~~~~~~~~
In file included from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from bank.cpp:1:
/usr/include/c++/10/bits/ios_base.h:1006:18: note: in passing argument 1 of 'std::ios_base& std::left(std::ios_base&)'
 1006 |   left(ios_base& __base)
      |        ~~~~~~~~~~^~~~~~
bank.cpp:11:62: error: 'paid' was not declared in this scope
   11 |  vi ppls(ppl), banknotes(banknote), left(1 << banknote, -1), paid(1 << banknote, -1);
      |                                                              ^~~~
bank.cpp:16:8: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   16 |  left[0] = 0;
      |        ^
bank.cpp:16:10: error: assignment of read-only location '* std::left'
   16 |  left[0] = 0;
      |  ~~~~~~~~^~~
bank.cpp:26:24: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   26 |     int cur = left[prev] + banknotes[last]; // current ppl
      |                        ^
bank.cpp:32:15: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   32 |      left[mask] = cur;
      |               ^
bank.cpp:32:17: error: assignment of read-only location '*(std::left + ((sizetype)mask))'
   32 |      left[mask] = cur;
      |      ~~~~~~~~~~~^~~~~
bank.cpp:37:15: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   37 |      left[mask] = 0;
      |               ^
bank.cpp:37:17: error: assignment of read-only location '*(std::left + ((sizetype)mask))'
   37 |      left[mask] = 0;
      |      ~~~~~~~~~~~^~~