# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
998312 | thisisadarsh | Bank (IZhO14_bank) | C++14 | 1 ms | 348 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;
const int sz=1002;
int n,m;
bool answer=true;
int a[sz], b[sz];
int main(){
scanf("%d%d", &n,&m);
for(int i=0; i<n; ++i){
scanf("%d", &a[i]);
}
for(int j=0; j<m; ++j){
scanf("%d", &b[j]);
}
for(int i=0; i<n; ++i){
sort(b, b+m);
int low=0, hi=m-1;
bool ok=false;
while(low<hi){
if(b[low]+b[hi]==a[i]){
b[low]=0,b[hi]=0;
ok=true;
break;
}
if(b[low]+b[hi]>a[i])hi--;
else low++;
}
if(!ok){
answer=false;
break;
}
}
printf("%s\n", (answer?"YES":"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... |