Skip to content

Commit

Permalink
보물
Browse files Browse the repository at this point in the history
  • Loading branch information
yewon-yw authored Apr 15, 2022
1 parent d62aa27 commit 02208f1
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions greedy_algorithm/1026.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include <iostream>
#include <algorithm>
using namespace std;
int A[50], B[50];

int compare(int a, int b) {
return a > b;
}

int main() {
int N, result = 0;
cin >> N;
for (int i = 0; i < N; i++) {
cin >> A[i];
}
for (int i = 0; i < N; i++) {
cin >> B[i];
}
sort(A, A + N);
sort(B, B + N, compare);

for (int i = 0; i < N; i++) {
result += A[i] * B[i];
}
cout << result;
}

0 comments on commit 02208f1

Please sign in to comment.