# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
671436 | 2022-12-13T05:01:08 Z | Alihan_8 | Bank (IZhO14_bank) | C++17 | 1 ms | 1108 KB |
#include <bits/stdc++.h> // include <ext/pb_ds/assoc_container.hpp> // include <ext/pb_ds/tree_policy.hpp> // using namespace __gnu_pbds; using namespace std; #define all(x) x.begin(), x.end() #define pb push_back // define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> #define mpr make_pair #define ln '\n' void IO(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);} #define int long long signed main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int n, m; cin >> n >> m; vector <int> a(n), b(m); for ( auto &i: a ) cin >> i; for ( auto &i: b ) cin >> i; const int N = 2e4+1; sort(all(a)); sort(all(b)); for ( auto i: a ){ vector <int> dp(N), ind(N); dp[0] = 1; ind[0] = -1; int it = 0; for ( auto val: b ){ for ( int j = N-1; j >= val; j-- ){ if ( ind[j-val] and !ind[j] ) dp[j] = j-val, ind[j] = it+1; } it++; } if ( !ind[i] ){ cout << "NO\n"; return 0; } vector <int> used((int)b.size()); while ( i ){ used[ind[i-1]] = 1; i = dp[i]; } vector <int> newb; for ( int j = 0; j < (int)b.size(); j++ ){ if ( !used[j] ) newb.pb(b[j]); } b = newb; } cout << "YES"; cout << '\n'; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 596 KB | Output is correct |
2 | Correct | 0 ms | 596 KB | Output is correct |
3 | Runtime error | 1 ms | 1108 KB | Execution killed with signal 6 |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 1108 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 596 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 596 KB | Output is correct |
2 | Correct | 0 ms | 596 KB | Output is correct |
3 | Runtime error | 1 ms | 1108 KB | Execution killed with signal 6 |
4 | Halted | 0 ms | 0 KB | - |