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 <algorithm>
using namespace std;
int Costs[110], Mbyte[110];
int main(){
int i, j, N, M;
cin >> N >> M;
for(i=0; i < N; ++i) cin >> Mbyte[i];
for(i=0; i < N; ++i) cin >> Costs[i];
for(i=0; i < N; ++i){
for(j=0; j < N; ++j){
if( Costs[i] < Costs[j] ){
swap( Costs[i], Costs[j] );
swap( Mbyte[i], Mbyte[j] );
} else if( Costs[i] == Costs[j] ){
if( Mbyte[i] < Mbyte[j] ){
swap( Costs[i], Costs[j] );
swap( Mbyte[i], Mbyte[j] );
}
}
}
}
int Msum=0, Csum=0;
for(i=0; i < N; ++i){
if( Msum < M ){
Msum += Mbyte[i];
Csum += Costs[i];
} else {
cout<< Csum <<'\n';
break;
}
}
return 0;
}
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |