Submission #90058

#TimeUsernameProblemLanguageResultExecution timeMemory
90058Rashidov_AnisBank (IZhO14_bank)C++14
19 / 100
540 ms888 KiB
#include <bits/stdc++.h> #define fr first #define se second #define sc scanf #define pf printf #define ld long double #define ll long long #define pb push_back #define sq(n) n * n #define r_0 return 0 #define pr pair < ll, ll > #define prr pair < pair < ll, ll >, ll > #define fin(s) freopen( s, "r", stdin ) #define fout(s) freopen( s, "w", stdout ) #define TIME ios_base::sync_with_stdio(0) using namespace std; const ll INF = 1e9; const ll N = 2e3 + 3; const ll mod = 998244353; const ld eps = 1e-7; ll n, m; ll ans; ll b[N], a[N]; vector < ll > v[N]; main(){ TIME; //fin( "bank.in" ); //fout( "bank.out" ); cin >> n >> m; for( int i = 1; i <= n; i ++ ){ cin >> a[i]; } for( int i = 1; i <= m; i ++ )cin >> b[i]; for( int i = 0; i <= ( 1 << m + 1 ); i ++ ){ ans = 0; vector < ll > g; for( int j = 0; j < m; j ++ ){ ll k = ( i >> j ) & 1; if( k == 1 )ans += b[j + 1], g.pb( j + 1 ); } if( ans <= N - 2 && v[ans].empty() )v[ans] = g; //cout << i << ' ' << ans << '\n'; } for( int i = 1; i <= n; i ++ ){ //cout << "=> " << a[i] << " "; if( v[a[i]].empty() ){ cout << "NO"; r_0; } for( auto u: v[a[i]] ){ //cout << u << ' '; if( !b[u] ){ cout << "NO"; r_0; } b[u] = 0; } //cout << endl; } cout << "YES"; }

Compilation message (stderr)

bank.cpp:28:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
bank.cpp: In function 'int main()':
bank.cpp:37:35: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
     for( int i = 0; i <= ( 1 << m + 1 ); i ++ ){
                                 ~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...