# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
388927 | DylanP | Bank (IZhO14_bank) | C++14 | 136 ms | 428 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,M,a;
scanf("%d %d",&M,&N);
vector<int> w;
vector<int> bill_nye;
for(int i=0;i<M;i++){
scanf("%d",&a);
bill_nye.push_back(a);
}
for(int i=0;i<N;i++){
scanf("%d",&a);
w.push_back(a);
}
int EXP=1<<N;
vector<bool> bitmask;
bitmask.resize(EXP);
bitmask[0]=true;
int wrestler=0;
vector<int> L;
for(int i=0;i<M;i++){
for(int j=0;j<bill_nye[i];j++){
L.push_back(i);
wrestler++;
}
}
for(int i=0;i<N;i++){
for(int j=0;j<w[i];j++){
L.push_back(299792458);
}
}
vector<int> YTP;
for(int i=1;i<EXP;i*=2){
YTP.push_back(INT_MAX-i);
}
for(int i=1;i<EXP;i++){
bitmask[i]=false;
int sumo=0;
for(int j=0;j<N;j++){
if((i>>j)%2){
sumo+=w[j];
}
}
for(int j=0;j<N;j++){
if(L[sumo-1]==L[sumo-w[j]-1]){
if(bitmask[i&YTP[j]]){
bitmask[i]=true;
if(sumo==wrestler){
wrestler=-314159265;
}
}
}
}
}
if(wrestler<0){
cout<<"YES";
}else{
cout<<"NO";
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |