# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
383347 | Iwanttobreakfree | Bank (IZhO14_bank) | C++98 | 1 ms | 364 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 <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
int n,m,sum;
cin>>n>>m;
vector<int> sal(n);
vector<int> bank(m);
for(int i=0;i<n;i++)cin>>sal[i];
for(int i=0;i<m;i++)cin>>bank[i];
sort(sal.rbegin(),sal.rend());
sort(bank.rbegin(),bank.rend());
vector<vector<int> > DP(n,vector<int>(m));
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
DP[i][j]=sal[i];
if(sal[i]<bank[j])continue;
else {
for(int q=0;q<j;q++){
int x=DP[i][q]-bank[j];
if(x<0)x*=-1;
DP[i][j]=min(x,DP[i][j]);
}
}
}
}
bool pos=true;
for(int i=0;i<n;i++){
if(DP[i][m-1]>0){
pos=false;
break;
}
}
if(pos)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... |