프로그래머스 - 최솟값 만들기
2022. 9. 17. 19:07ㆍ코딩 공부 연습
반응형
가장 작은수랑 가장 큰수를 짝지어서 곱해주면 된다. 쉽다!!!
#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.begin(), B.end(), greater());
for(int i = 0; i< A.size(); i++)
answer += A[i]*B[i];
return answer;
}
16242등
'코딩 공부 연습' 카테고리의 다른 글
백준 - n과m 시리즈 (0) | 2022.09.19 |
---|---|
프로그래머스 - 숫자의 표현 (0) | 2022.09.17 |
프로그래머스 - 124 나라의 숫자 (0) | 2022.09.17 |
프로그래머스 - JadenCase 문자열 만들기 (0) | 2022.09.15 |
프로그래머스 - 최댓값과 최솟값 (0) | 2022.09.15 |