# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
765741 | 2023-06-25T04:22:10 Z | tinhngoVN | 은행 (IZhO14_bank) | C++14 | 15 ms | 33236 KB |
#include <bits/stdc++.h> #define MAXN 22 using namespace std; int n,m,a[MAXN], b[MAXN]; int amt[1<<MAXN] , cnta[1<<MAXN]; //amt[i] la so tien con lai khi tra luong cho mot so nguoi o trang thai nhung to tien la i //cnta[i] la so nguoi duoc tra luong o trang thai nhung to tien la i void inp() { cin>>n>>m; for (int i=0; i<n; ++i) cin>>a[i]; for (int i=0; i<m; ++i) cin>>b[i]; } void out() { memset(amt , -1 , sizeof(amt)); memset(cnta , -1 , sizeof(cnta)); amt[0]=0; cnta[0]=0; for (int mask=0; mask<(1<<m); ++mask) { for (int i=0; i<m; ++i) { if (mask&(1<<i)) { int pre_mask = mask & ~(1<<i); if(cnta[pre_mask] == -1) continue; //Neu so nguoi o trang thai truoc chua duoc tinh int new_amt = amt[pre_mask] + b[i]; int cur = a[cnta[pre_mask]]; if(new_amt < cur) { cnta[mask] = cnta[pre_mask]; amt[mask] = new_amt; } else if (new_amt==cur) { cnta[mask] = cnta[pre_mask]+1; amt[mask] = 0; } } } if(cnta[mask] == n) { cout<<"YES\n"; return ; } } cout<<"NO\n"; } int main() { ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr); freopen("bank.inp" , "r" , stdin); freopen("bank.out" , "w" , stdout); inp(); out(); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 15 ms | 33236 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 13 ms | 33140 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 13 ms | 33128 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 15 ms | 33236 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |