Submission #90056

# Submission time Handle Problem Language Result Execution time Memory
90056 2018-12-20T04:58:44 Z Rashidov_Anis Bank (IZhO14_bank) C++14
0 / 100
3 ms 744 KB
#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] << " ";
        for( auto u: v[a[i]] ){
            //cout << u << ' ';
            if( !b[u] ){ cout << "NO"; r_0; }
            b[u] = 0;
        }
        //cout << endl;
    }
    cout << "YES";
}

Compilation message

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 ++ ){
                                 ~~^~~
bank.cpp:13:23: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
 #define fin(s) freopen( s, "r", stdin )
                ~~~~~~~^~~~~~~~~~~~~~~~~
bank.cpp:30:5: note: in expansion of macro 'fin'
     fin( "bank.in" );
     ^~~
bank.cpp:14:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
 #define fout(s) freopen( s, "w", stdout )
                 ~~~~~~~^~~~~~~~~~~~~~~~~~
bank.cpp:31:5: note: in expansion of macro 'fout'
     fout( "bank.out" );
     ^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 744 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -