Submission #1089280

#TimeUsernameProblemLanguageResultExecution timeMemory
1089280vjudge1Bank (IZhO14_bank)C++17
71 / 100
1036 ms1996 KiB
//#pragma GCC optimize ("O3") //#pragma GCC target ("sse4") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define ll long long #define ld long double #define ull unsigned long long #define pb push_back #define pob pop_back //#define int long long #define int2 __int128_t #define Shrek_Crush228 ios_base::sync_with_stdio(0), cin.tie(0); #define F first #define S second #define FOR( i, x, n, d ) for( int i = x; i <= n; i += d ) #define FORR( i, x, n, d ) for( int i = x; i >= n; i -= d ) #define lb lower_bound #define ub upper_bound #define all(x) x.begin(), x.end() #define no cout << "NO\n" #define yes cout << "YES\n" #define nep next_permutation #define sigma signed #define pii pair <int, int> using namespace std; string alp = "abcdefghijklmnopqrstuvwxyz"; string ae = "aoeiuy"; string nums = "123456789"; const int N = 1e5 + 123; const int inf = 1e18; const int MOD = 1e9 + 7; const int MOD1 = 998244353; const long long maxsum = 1e14; int a[N], b[N], c[N], l, r, n, k, m, w, sum, sum1, y, ans1, mx = -inf, mn = inf, ind, ind1, pref[N], suf[N]; string s, s1; ll ans, x; template<class T> using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>; struct RT { int sum, l, r, ind; }; int gcd( int a, int b ) { return ( b ? gcd( b, a % b ) : a ); } int lcm( int a, int b ) { return a / gcd( a, b ) * b; } int bp( int a, int b, int m ) { if( !b ) return 1; if( b & 1 ) return bp( a, b >> 1, m ) * bp( a, b >> 1, m ) % m * a % m; else return bp( a, b >> 1, m ) * bp( a, b >> 1, m ) % m; } struct po { int mn, sum, mx; }; int nt[N], taked[N]; bool ok; map <string, bool> mp[22]; vector <string> v[22]; void mask( int i, string s, int need, int st, int sum = 0, string ss = "" ) { if( i == m ) { if( sum != need || mp[st][ss] ) return; mp[st][ss] = 1; v[st].pb( ss ); return; } mask( i + 1, s, need, st, sum, ss + s[i] ); if( s[i] == '0' ) mask( i + 1, s, need, st, sum + b[i + 1], ss + '1' ); } void rec( int i, string s ) { if( i > n ) { ok = 1; return; } mask( 0, s, a[i], i ); for( auto mas : v[i] ) { rec( i + 1, mas ); if( ok ) return; } } void solve() { cin >> n >> m; string nw = ""; FOR( i, 1, n, 1 ) cin >> a[i]; FOR( i, 1, m, 1 ) cin >> b[i], nw += '0'; rec( 1, nw ); if( ok ) cout << "YES\n"; else cout << "NO\n"; } sigma main() { //freopen("rmq.in", "r", stdin); //freopen("rmq.out", "w", stdout); Shrek_Crush228 int test = 1; if( !test ) cin >> test; while( test -- ) { solve(); } } // solved by KluydQ

Compilation message (stderr)

bank.cpp:37:17: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   37 | const int inf = 1e18;
      |                 ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...