Submission #550766

# Submission time Handle Problem Language Result Execution time Memory
550766 2022-04-19T05:25:34 Z AJ00 Bank (IZhO14_bank) C++14
19 / 100
61 ms 212 KB
#include <bits/stdc++.h>

using namespace std;
int from[20],achieve[20];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int tc=1,n,q,k,m; 
    //cin >> tc;
    for (int poppo = 1; poppo <= tc; poppo++){
        cin >> n >> m;
        for (int i = 0; i < n; i++){
            cin >> achieve[i];
        }
        sort(achieve,achieve+n);
        for (int i = 0; i < m; i++){
            cin >> from[i];
        }
        sort(from,from+m);
        bool pos = false;
        for (int mask = 0; mask < (1<<m); mask++){
            int cursum = 0,curitr=0;
            for (int i = 0; i < m; i++){
                if ((1<<i)&mask){
                    cursum += from[i];
                    if (cursum == achieve[curitr]){
                        curitr++;
                        cursum = 0;
                    }
                }
            }
            if (curitr == n){
                pos = true;
                break;
            }
        }
        pos ? cout << "YES\n" : cout << "NO\n";
    }
    return 0;
}

Compilation message

bank.cpp: In function 'int main()':
bank.cpp:9:16: warning: unused variable 'q' [-Wunused-variable]
    9 |     int tc=1,n,q,k,m;
      |                ^
bank.cpp:9:18: warning: unused variable 'k' [-Wunused-variable]
    9 |     int tc=1,n,q,k,m;
      |                  ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 61 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 2 ms 212 KB Output is correct
9 Correct 61 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 61 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 2 ms 212 KB Output is correct
9 Correct 61 ms 212 KB Output is correct
10 Incorrect 0 ms 212 KB Output isn't correct
11 Halted 0 ms 0 KB -