제출 #990972

#제출 시각아이디문제언어결과실행 시간메모리
990972mindiyak은행 (IZhO14_bank)C++14
71 / 100
1069 ms348 KiB
#include <bits/stdc++.h> #include <string> #include <iostream> #include <cmath> #include <numeric> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair<int, int> pi; typedef pair<int, int> pl; typedef pair<ld, ld> pd; typedef vector<int> vi; typedef vector<bool> vb; typedef vector<vector<int>> vvi; typedef vector<ld> vd; typedef vector<long> vl; typedef vector<pi> vpi; typedef vector<pl> vpl; #define FOR(i, a, b) for (int i = a; i < (b); i++) #define F0R(i, a) for (int i = 0; i < (a); i++) #define FORd(i, a, b) for (int i = (b)-1; i >= a; i--) #define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--) #define trav(a, x) for (auto &a : x) #define uid(a, b) uniform_int_distribution<int>(a, b)(rng) #define len(x) (int)(x).size() #define mp make_pair #define pb push_back #define fst first #define nl endl #define sec second #define lb lower_bound #define ub upper_bound #define aint(x) x.begin(), x.end() #define raint(x) x.rbegin(), x.rend() #define ins insert const int MOD = 1000000007; void init() { #ifndef ONLINE_JUDGE freopen("input.in", "r", stdin); freopen("output.out", "w", stdout); #endif } void fastIO() { ios_base::sync_with_stdio(0); cin.tie(0); } bool can = false; int n,m; void dfs(vi people,vi money,int sum,int sum2){ if(can)return; if(sum == 0){ can = true; return; } if(sum2<sum)return; if(money.size()==0)return; bool temp_can = true; int mon = money[0]; sum2-=mon; money.erase(money.begin()); dfs(people,money,sum,sum2); FOR(i,0,n){ if(people[i]!=0)temp_can = false; if(people[i]>=mon){ people[i]-=mon; dfs(people,money,sum-mon,sum2); people[i]+=mon; } } if(temp_can)can = true; } void solve() { cin>>n>>m;can = false; int sum = 0,sum2 = 0; vi people(n);vi money(m); FOR(i,0,n)cin>>people[i]; FOR(i,0,m)cin>>money[i]; FOR(i,0,n)sum+=people[i]; FOR(i,0,m)sum2+=money[i]; sort(people.rbegin(),people.rend()); sort(money.rbegin(),money.rend()); dfs(people,money,sum,sum2); if(can)cout << "YES" << endl; else cout << "NO" << endl; } int main() { fastIO(); // init(); int t = 1; // cin >> t; while (t--) solve(); return 0; }

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

bank.cpp: In function 'void init()':
bank.cpp:41:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |     freopen("input.in", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
bank.cpp:42:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |     freopen("output.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...