제출 #1001489

#제출 시각아이디문제언어결과실행 시간메모리
1001489reginox은행 (IZhO14_bank)C++17
0 / 100
1098 ms46676 KiB
#include<bits/stdc++.h> #define ll long long #define ld long double #define all(v) begin(v), end(v) #define pi pair<int, int> #define vi vector<int> #define task "test" using namespace std; ll n,m,dp[1<<21],a[21],b[21]; vi v[1000005]; int main(){ if(fopen(task".inp","r")){ freopen(task".inp","r",stdin); freopen(task".out","w",stdout); } ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> m; for(ll i = 0; i < n; i++) cin >> a[i]; for(ll i = 0; i < m; i++) cin >> b[i]; for(ll msk = 1; msk < 1<<m; msk++){ ll sum = 0; for(ll i = 0; i < m; i++){ if(msk>>i&1) sum += b[i]; } v[sum].push_back(msk); } memset(dp,-1,sizeof(dp)); dp[0] = 0; for(ll i = 0; i < n; i++){ for(ll msk = (1<<m)-1; msk >= 0; msk--){ if(dp[msk] == 1) continue; for(ll sub:v[a[i]]){ if(sub & msk) continue; dp[sub|msk] = dp[msk]+1; if(dp[sub|msk] == n){ cout << "YES"; return 0; } } } } cout << "NO"; return 0; }

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

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