제출 #935972

#제출 시각아이디문제언어결과실행 시간메모리
935972Bula은행 (IZhO14_bank)C++17
100 / 100
109 ms16976 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int mod = 1e9 + 7, N = 2e5 + 5; main(){ ios::sync_with_stdio(0); cin.tie(0),cout.tie(0); int tt = 1; //cin >> tt; while(tt--){ int n, m; cin >> n >> m; vector<int> a(n), b(m); for(int i = 0; i < n; i++) cin >> a[i]; for(int i = 0; i < m; i++) cin >> b[i]; vector<int> ans((1 << m), -1), left((1 << m), -1); ans[0] = left[0] = 0; for(int i = 0; i < (1 << m); i++){ for(int j = 0; j < m; j++){ if(!(i & (1 << j))) continue; int p = i & ~(1 << j); if(ans[p] == -1) continue; int sum = left[p] + b[j]; int need = a[ans[p]]; if(sum < need){ ans[i] = ans[p]; left[i] = sum; }else if(sum == need){ ans[i] = ans[p] + 1; left[i] = 0; } } if(ans[i] == n){ cout << "YES" << endl; return 0; } } cout << "NO" << endl; } }

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

bank.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    6 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...