# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
738464 |
2023-05-08T19:48:26 Z |
MODDI |
Bank (IZhO14_bank) |
C++14 |
|
1 ms |
340 KB |
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<long long, long long> pll;
typedef pair<int,int> pii;
typedef vector<long long> vl;
typedef vector<int> vi;
int n, m;
vi banknotes, salary;
bool dp[2][(1<<20)];
bool check_bit(int n, int bit){
int ok = n & (1 << bit);
if(ok) return true;
return false;
}
int set_bit(int n, int b){
return (n | (1 << b));
}
int main(){
cin>>n>>m;
banknotes.resize(m);
salary.resize(n);
for(int i = 0; i < n; i++) cin>>salary[i];
for(int i = 0; i < m; i++) cin>>banknotes[i];
sort(salary.begin(), salary.end());
if(n == 1){
bool can[m][1001];
memset(can, false, sizeof can);
can[0][0] = can[0][banknotes[0]] = true;
for(int i = 1; i < m; i++){
for(int j = 0; j <= 1000; j++){
can[i][j] |= can[i-1][j];
if(j >= banknotes[i])
can[i][j] |= can[i-1][j-banknotes[i]];
}
}
if(can[m-1][salary[0]]) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
else
cout<<"NO"<<endl; //TODO
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
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 |
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 |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |