# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
972799 |
2024-05-01T08:01:41 Z |
saidpon |
Bank (IZhO14_bank) |
C++14 |
|
79 ms |
35672 KB |
#include <bits/stdc++.h>
#define ordered_set tree <int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define nemeshay ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define allr(pon) pon.rbegin(), pon.rend()
#include <ext/pb_ds/assoc_container.hpp>
#define all(pon) pon.begin(), pon.end()
#include <ext/pb_ds/tree_policy.hpp>
#define pii pair <int, int>
#define nosolve puts("-1")
#define YES puts("YES")
#define pb push_back
#define pf push_front
#define int long long
#define OK puts("OK")
#define NO puts("NO")
#define sigma signed
#define sc second
#define fr first
using namespace __gnu_pbds;
using namespace std;
const int N = 1e6 + 20, INF = 2e9 + 7;
int a[N], b[N], dp[N];
vector <int> pon[N];
sigma main(){
nemeshay
int n, m;
cin >> n >> m;
for (int i = 0; i < n; i++) cin >> a[i];
for (int i = 0; i < m; i++) cin >> b[i];
for (int i = 0; i < n; i++){
for (int l = 0; l < (1 << m); l++){
int sum = 0;
for (int j = 0; j < m; j++){
if (!(l & (1 << j))) sum += b[j];
}
if (sum == a[i]) pon[i].pb(l);
}
}
for (int i = 1; i < N; i++) dp[i] = -1;
for (int i = 0; i < n; i++){
for (int l = (1 << m) - 1; l >= 0; l--){
if (dp[l] != -1){
for (auto j: pon[i]){
if (!(l & j)){
dp[l | j] = dp[l] + 1;
}
if (dp[l | j] == n){
YES;
return 0;
}
}
}
}
}
NO;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
35420 KB |
Output is correct |
2 |
Correct |
10 ms |
35420 KB |
Output is correct |
3 |
Correct |
9 ms |
35528 KB |
Output is correct |
4 |
Correct |
9 ms |
35416 KB |
Output is correct |
5 |
Correct |
73 ms |
35508 KB |
Output is correct |
6 |
Correct |
8 ms |
35416 KB |
Output is correct |
7 |
Correct |
7 ms |
35672 KB |
Output is correct |
8 |
Correct |
76 ms |
35408 KB |
Output is correct |
9 |
Correct |
79 ms |
35408 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
35416 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
14 ms |
35420 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
35420 KB |
Output is correct |
2 |
Correct |
10 ms |
35420 KB |
Output is correct |
3 |
Correct |
9 ms |
35528 KB |
Output is correct |
4 |
Correct |
9 ms |
35416 KB |
Output is correct |
5 |
Correct |
73 ms |
35508 KB |
Output is correct |
6 |
Correct |
8 ms |
35416 KB |
Output is correct |
7 |
Correct |
7 ms |
35672 KB |
Output is correct |
8 |
Correct |
76 ms |
35408 KB |
Output is correct |
9 |
Correct |
79 ms |
35408 KB |
Output is correct |
10 |
Incorrect |
8 ms |
35416 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |