# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
971757 |
2024-04-29T09:00:56 Z |
saidpon |
Bank (IZhO14_bank) |
C++17 |
|
12 ms |
29016 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;
vector <int> pon[N];
int a[N], b[N], dp[N];
sigma main(){
nemeshay
map <int, bool> sigmapon;
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];
sigmapon[i] = 0;
}
for (int i = 0; i < n; i++){
for (int j = 1; j <= a[i]; j++) dp[j] = INF;
for (int j = 0; j < m; j++) {
if (!sigmapon[j]) {
for (int k = b[j]; k <= a[i]; k++) {
if (dp[k - b[j]] + 1 < dp[k]) {
dp[k] = dp[k - b[j]] + 1;
pon[k] = pon[k - b[j]];
pon[k].pb(j);
}
}
}
}
if (dp[a[i]] == INF){
NO;
return 0;
}
for (auto j: pon[a[i]]) sigmapon[j] = 1;
}
YES;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
24664 KB |
Output is correct |
2 |
Incorrect |
10 ms |
24664 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
24664 KB |
Output is correct |
2 |
Correct |
8 ms |
28764 KB |
Output is correct |
3 |
Correct |
8 ms |
29016 KB |
Output is correct |
4 |
Incorrect |
10 ms |
24668 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
9 ms |
24668 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
24664 KB |
Output is correct |
2 |
Incorrect |
10 ms |
24664 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |