# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
980926 | 2024-05-12T15:50:50 Z | khanhtb | 은행 (IZhO14_bank) | C++14 | 1000 ms | 23380 KB |
#include<bits/stdc++.h> #define ll long long #define ull unsigned long long #define ld double #define pb push_back #define pf push_front #define vi vector<ll> #define vll vector<vi> #define pll pair<ll,ll> #define vpll vector<pll> #define all(a) a.begin(), a.end() #define fi first #define se second using namespace std; const ll mod = 1e9+7; const ll inf = 1e18; const ll base = 26; const ll blocksz = 320; const ll N = 3e3+8; const ll buff = 2e7+8; ll n,m,dp[21][1<<20],w[21][1<<20],a[21],b[21]; vi premask[N]; void solve(){ cin >> n >> m; for(ll i = 1; i <= n; i++) cin >> a[i]; for(ll i = 0; i < m; i++) cin >> b[i]; for(ll mask = 0; mask < 1<<m; mask++){ ll sum = 0; for(ll i = 0; i < m; i++){ if(mask>>i&1) sum += b[i]; } premask[sum].pb(mask); } for(ll mask = 0; mask < 1<<m; mask++) dp[0][mask] = 1; for(ll i = 1; i <= n; i++){ for(ll mask = 0; mask < 1<<m; mask++){ for(ll submask:premask[a[i]]){ if((mask|submask) == mask){ ll exclude = mask^submask; dp[i][mask] |= dp[i-1][exclude]; } } } } cout << (dp[n][(1<<m)-1]?"YES":"NO"); } signed main(){ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); if(fopen("test.inp","r")){ freopen("test.inp","r",stdin); freopen("test.out","w",stdout); } int T = 1; // cin >> T; while(T--){ solve(); cout << '\n'; } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 4444 KB | Output is correct |
2 | Correct | 1 ms | 2396 KB | Output is correct |
3 | Correct | 1 ms | 4444 KB | Output is correct |
4 | Correct | 10 ms | 9156 KB | Output is correct |
5 | Correct | 73 ms | 22892 KB | Output is correct |
6 | Correct | 1 ms | 2396 KB | Output is correct |
7 | Correct | 1 ms | 4444 KB | Output is correct |
8 | Execution timed out | 1018 ms | 23380 KB | Time limit exceeded |
9 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 10584 KB | Output is correct |
2 | Correct | 2 ms | 8536 KB | Output is correct |
3 | Correct | 1 ms | 6492 KB | Output is correct |
4 | Correct | 1 ms | 10588 KB | Output is correct |
5 | Correct | 2 ms | 16732 KB | Output is correct |
6 | Correct | 2 ms | 12636 KB | Output is correct |
7 | Correct | 2 ms | 8540 KB | Output is correct |
8 | Correct | 2 ms | 10588 KB | Output is correct |
9 | Correct | 1 ms | 8540 KB | Output is correct |
10 | Runtime error | 7 ms | 856 KB | Execution killed with signal 11 |
11 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 7 ms | 604 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 4444 KB | Output is correct |
2 | Correct | 1 ms | 2396 KB | Output is correct |
3 | Correct | 1 ms | 4444 KB | Output is correct |
4 | Correct | 10 ms | 9156 KB | Output is correct |
5 | Correct | 73 ms | 22892 KB | Output is correct |
6 | Correct | 1 ms | 2396 KB | Output is correct |
7 | Correct | 1 ms | 4444 KB | Output is correct |
8 | Execution timed out | 1018 ms | 23380 KB | Time limit exceeded |
9 | Halted | 0 ms | 0 KB | - |