답안 #330701

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
330701 2020-11-26T09:32:25 Z hakanai 은행 (IZhO14_bank) C++17
71 / 100
1000 ms 17588 KB
// https://oj.uz/problem/view/IZhO14_bank

#include <bits/stdc++.h>

using namespace std;

const int N = 1010;
vector<int> mp[N];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int> a(n), b(m);
    for ( int i=0; i<n; i++ ) cin >> a[i];
    for ( int i=0; i<m; i++ ) cin >> b[i];
    for ( int s=1; s<1<<m; s++ ) {
        int res = 0;
        for ( int i=0; i<m; i++ ) {
            if ( s>>i&1 ) res += b[i]; 
        }
        if ( res<N ) mp[res].push_back(s); 
    }
    set<int> avail;
    avail.insert((1<<m) - 1);
    for ( int i=0; i<n; i++ ) {
        set<int> navail;
        bool ok = false;
        for ( int t:mp[a[i]] ) {
            for ( int s:avail ) {
                if ( (t&s)==t) {
                    if ( (s^t)>0&&navail.count(s^t)==0 )
                        navail.insert(s^t);
                    ok = true;
                }
            }
        }
        if ( !ok ) {
            cout << "NO" << '\n';
            return 0;
        }
        avail = navail;
    }
    cout << "YES" << '\n';
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 3 ms 620 KB Output is correct
5 Correct 85 ms 6764 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 82 ms 6252 KB Output is correct
9 Correct 81 ms 6380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 364 KB Output is correct
2 Correct 2 ms 364 KB Output is correct
3 Correct 2 ms 364 KB Output is correct
4 Correct 2 ms 492 KB Output is correct
5 Correct 2 ms 492 KB Output is correct
6 Correct 2 ms 364 KB Output is correct
7 Correct 2 ms 364 KB Output is correct
8 Correct 2 ms 364 KB Output is correct
9 Correct 2 ms 364 KB Output is correct
10 Correct 2 ms 364 KB Output is correct
11 Correct 2 ms 492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 3 ms 620 KB Output is correct
5 Correct 85 ms 6764 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 82 ms 6252 KB Output is correct
9 Correct 81 ms 6380 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 512 KB Output is correct
20 Correct 2 ms 364 KB Output is correct
21 Correct 2 ms 364 KB Output is correct
22 Correct 2 ms 364 KB Output is correct
23 Correct 2 ms 492 KB Output is correct
24 Correct 2 ms 492 KB Output is correct
25 Correct 2 ms 364 KB Output is correct
26 Correct 2 ms 364 KB Output is correct
27 Correct 2 ms 364 KB Output is correct
28 Correct 2 ms 364 KB Output is correct
29 Correct 2 ms 364 KB Output is correct
30 Correct 2 ms 492 KB Output is correct
31 Correct 90 ms 5740 KB Output is correct
32 Correct 791 ms 6380 KB Output is correct
33 Correct 83 ms 1260 KB Output is correct
34 Correct 74 ms 364 KB Output is correct
35 Correct 75 ms 364 KB Output is correct
36 Correct 79 ms 364 KB Output is correct
37 Correct 73 ms 620 KB Output is correct
38 Correct 73 ms 492 KB Output is correct
39 Correct 362 ms 16604 KB Output is correct
40 Correct 93 ms 2156 KB Output is correct
41 Correct 74 ms 876 KB Output is correct
42 Correct 127 ms 5868 KB Output is correct
43 Correct 77 ms 2284 KB Output is correct
44 Correct 73 ms 364 KB Output is correct
45 Correct 99 ms 6636 KB Output is correct
46 Correct 83 ms 3564 KB Output is correct
47 Correct 74 ms 364 KB Output is correct
48 Correct 83 ms 6124 KB Output is correct
49 Correct 82 ms 6124 KB Output is correct
50 Execution timed out 1050 ms 17588 KB Time limit exceeded
51 Halted 0 ms 0 KB -