제출 #958370

#제출 시각아이디문제언어결과실행 시간메모리
958370FanOfWilliamLin은행 (IZhO14_bank)C++14
0 / 100
79 ms81912 KiB
#include <bits/stdc++.h> using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; template <class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #define int long long #define ll long long #define ld long double #define ar array #define vt vector #define pb push_back #define bit(i, x) ((x>>i)&1ULL) #define pf push_front #define all(v) v.begin(), v.end() #define lla(v) v.rbegin(), v.rend() const ll INF=1e18; const ll MOD=1e9+7; const ll M=(1ll<<61)-1; //const ll MOD=998244353; mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); const ll base=uniform_int_distribution<ll>(0, M-1)(rng); ll bpow(ll a, ll b, ll DOMDOM) { a%=DOMDOM; ll res=1; while(b>0) { if(b&1) res=res*a%DOMDOM; a=a*a%DOMDOM; b>>=1; } return res; } ll floor_div(ll x, ll y) { assert(y!=0); if (y<0) { y=-y; x=-x; } if (x>=0) return x/y; return (x+1)/y-1; } ll ceil_div(ll x, ll y) { assert(y!=0); if (y<0) { y=-y; x=-x; } if (x<=0) { return x/y; } return (x-1)/y+1; } const int d4i[4]={-1, 0, 1, 0}, d4j[4]={0, 1, 0, -1}; const int d8i[8]={-1, -1, 0, 1, 1, 1, 0, -1}, d8j[8]={0, 1, 1, 1, 0, -1, -1, -1}; void tmw() { //solve here int n, m; cin >> n >> m; vt<int> a(n), b(m); for(auto& ele: a) { cin >> ele; } for(auto& ele: b) { cin >> ele; } vt<int> cover((1<<m)+1, -1); vt<int> left((1<<m)+1, -1); cover[0]=0; left[0]=0; for(int msk=1; msk<(1<<m); ++msk) { for(int i=0; i<m; ++i) { if(!bit(i, msk)) { continue; } int pre_msk=msk-(1<<i); int new_amt=left[pre_msk]+b[i]; int target=a[cover[pre_msk]]; if(new_amt<target) { cover[msk]=cover[pre_msk]; left[msk]=new_amt; } else if(new_amt==target) { cover[msk]=cover[pre_msk]+1; left[msk]=0; } } if(cover[msk]==n) { cout << "YES\n"; return; } } cout << "NO\n"; } signed main() { ios::sync_with_stdio(0); cin.tie(0); freopen("bank.in", "r", stdin); freopen("bank.out", "w", stdout); int TC=1; //cin >> TC; while(TC--) { tmw(); } }

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

bank.cpp: In function 'int main()':
bank.cpp:110:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  110 |  freopen("bank.in", "r", stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
bank.cpp:111:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  111 |  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...