코딩 테스트/프로그래머스 코딩테스트
최솟값 만들기
ingus kinematics
2022. 10. 3. 18:45
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int solution(vector<int> A, vector<int> B)
{
int answer = 0;
sort(A.begin(), A.end());
sort(B.rbegin(), B.rend());
// Sum
for(int i=0; i<A.size(); i++)
{
// answer += A[i] * B[i];
answer += A.at(i) * B.at(i);
}
// cout << "answer = " << answer << endl;
return answer;
}