제출 #988224

#제출 시각아이디문제언어결과실행 시간메모리
988224Tsagana은행 (IZhO14_bank)C++14
0 / 100
252 ms81944 KiB
#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(vector<int> a, vector<int> b) {
	while (!a.empty() && a.back() == 0) a.pp();
	if (!b.empty()) b.pp();
	if (a.empty()) return 1;
	if (b.empty()) return 0;
	for (int i = 0; i < b.size(); i++) {
		if (b[i] >  a.back()) continue ;
		
		a[a.size()-1] -= b[i];
		swap(b[i], b[b.size()-1]);
		
		if (rep(a, b)) return 1;

		swap(b[i], b[b.size()-1]);
		a[a.size()-1] += b[i];

	}
	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();
	while (!b.empty() && !a.empty() && b.back() == a.back())
	{a.pp(); b.pp();} a.pb(0); b.pb(0);

	if (rep(a, b)) cout << "YES";
	else cout << "NO";
	// ???
	// zero
	// ???
}
signed main() {
	IOS 
	#ifndef LOCAL
		freopen("bank.in", "r", stdin);
		freopen("bank.out", "w", stdout);
	#endif

	solve();
	return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

bank.cpp: In function 'bool rep(std::vector<long long int>, std::vector<long long int>)':
bank.cpp:21: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]
   21 |  for (int i = 0; i < b.size(); i++) {
      |                  ~~^~~~~~~~~~
bank.cpp: In function 'int main()':
bank.cpp:57:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   57 |   freopen("bank.in", "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
bank.cpp:58:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   58 |   freopen("bank.out", "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...