-
Notifications
You must be signed in to change notification settings - Fork 2
20-mj010504 #74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
20-mj010504 #74
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์ฝ๊ฒ ํ๋ฆด ๊ฑฐ ์ฒ๋ผ ๋ณด์ด๋ ๋ฌธ์ ์ค์์ ์ง์ง ์ด๋ ค์ด ๋ฌธ์ ๋ผ๊ณ ์๊ฐํฉ๋๋ค...
๋จผ์ ๋ธ๋ฃจํธํฌ์ค๋ก ํ ๋, ์ต์ ์ ์ฐ์ฐํ์๋ฅผ ์๊ฐํด๋ด ์๋ค.
๊ฐ ๋์์ ์ ๋ ์ด ๋ฐฉ๋ฒ์ ์๋๋ค๊ณ ์๊ฐํ์ต๋๋ค.
์ด๋ป๊ฒ ๋ณต์ก๋๋ฅผ ์ค์ผ๊น๋ฅผ ๊ณ ๋ฏผํ๋ค๊ฐ DP๊ฐ ๋ ์ฌ๋๋๋ฐ
๋ก ์ ์ํ๊ณ ์ด๊ธฐ๊ฐ์
์์ง ์๋ฌด ์ฃผ์ฌ์๋ ์ ๋์ก์ ๋, ํฉ์ด 0์ด ๋๋ ๊ฒฝ์ฐ์ ์๋ฅผ 1์ด๋ผ๊ณ ์๊ฐํ๋ ๊ฒ ์
๋๋ค.
์์ ๋ฒ์ฃ ๋ฌธ์ ๋ ์ ์ฌํ ์์ด๋์ด์
๋๋ค.
์ด ๋ฉ๋๋ค. ์์ด๋ผ ๋ณต์กํ๋ฐ ๋ง๋ก ์ค๋ช
ํ๋ฉด
์ด๋ฒ ์ฃผ์ฌ์์์
dp ๋ฌธ์ ์ค์ 1, 2, 3๋ง ๋ํด์ ํน์ ์ซ์ ๋ง๋๋ ๋ฌธ์ ๋ ๋น์ทํ ๋
ผ๋ฆฌ์
๋๋ค.
๊ทผ๋ฐ ์ฌ์ค ์ด๋ ๊ฒ ํ ํ์๊ฐ ์ ํ ์์ต๋๋ค.
๋ฏผ์ค ๋ ํ์ด๋ ๊ทธ๋ฅ ์ฌ์ด ๋ฐฉ๋ฒ์ผ๋ก for ๋ฌธ์ผ๋ก ๋ชจ๋ ์ฃผ์ฌ์ ๋์ ํฉ์ ๊ตฌํ๋๋ฐ ์ ํต๊ณผ๊ฐ ๋๋์ง ์๊ฐํด๋ดค๋๋ฐ, ์ ๊ฐ ์ฐ์ฐ ํ์๋ฅผ ์๋ชป ๊ณ์ฐํ์ต๋๋ค.
์ฃผ์ฌ์ ๋์ ํฉ์ A ํฉ ๋ฐ๋ก B ํฉ ๋ฐ๋ก ๊ตฌํ๋ ๊ฑฐ๋๊น ๋์ ๊ณฑํ๋๊ฒ ์๋๋ผ ๋ํด์ผํฉ๋๋ค.
์ ํํ ์ฐ์ฐํ์๋ฅผ ๊ตฌํ๋ฉด
์
๋๋ค. ๋ฐ๋ผ์ ๊ทธ๋ฅ ๊ตฌํด๋ ์ถฉ๋ถํฉ๋๋ค...
์๋ฌดํผ DP๋ก A์ B์ ์ฃผ์ฌ์ ๋์ ํฉ์ ๊ฒฝ์ฐ์ ์๋ฅผ ๋ด์ ๋ฐฐ์ด์ ๊ตฌํ๊ณ
B์ ๋์ ํฉ ๋ฐฐ์ด์ ํตํด์ A๊ฐ ์ด๊ธฐ๋ ๊ฒฝ์ฐ์ ์๋ฅผ ๊ตฌํ์ต๋๋ค.

A[i], B[i]๋ A ๋๋ B๊ฐ ์ฃผ์ฌ์๋ฅผ ๋์ ธ์ ํฉ์ i๋ก ๋ง๋๋ ๊ฒฝ์ฐ์ ์์ด๊ณ
A๊ฐ ์ด๊ธฐ๋ ๊ฒฝ์ฐ์ ์๋ A[i] > 0 ์ผ ๋, A[i] * (B[1] + B[2] + ... + B[i-1])๋ฅผ ๋ชจ๋ i์ ๋ํด ๋ํ ๊ฐ์ด ๋ฉ๋๋ค.
๋งค๋ฒ B[1] + B[2] + ... + B[i-1]๋ฅผ ์ง์ ๊ตฌํ๋ฉด ์๊ฐ์ด๊ณผ์ ์ํ์ด ์์ผ๋ฏ๋ก ๋์ ํฉ์ ์ฌ์ฉํ์ต๋๋ค.
์ฃผ์ฌ์ ๊ตด๋ฆฌ๊ธฐ
from itertools import combinations
def solve(dice_set):
n = len(dice_set)
max_value = sum(max(d) for d in dice_set)
dp = [[0] * (max_value+1) for _ in range(n+1)]
dp[0][0] = 1
for i, faces in enumerate(dice_set, start=1):
for s in range(max_value+1):
for v in faces:
if s + v <= max_value:
dp[i][s + v] += dp[i-1][s]
return dp[n]
def solution(dice):
answer = []
max_count = -1
n = len(dice)
combs = combinations(range(n), n // 2)
for comb in combs:
# A, B ์ฃผ์ฌ์ ์ ํ
comb_set = set(comb)
a_dice = [dice[i] for i in range(n) if i in comb_set]
b_dice = [dice[i] for i in range(n) if i not in comb_set]
# A, B๊ฐ ๋ง๋ค ์ ์๋ ์ฃผ์ฌ์ ํฉ์ ๊ฒฝ์ฐ์ ์ ๊ตฌํ๊ธฐ
A = solve(a_dice)
B = solve(b_dice)
# B ๋์ ํฉ ๋ฐฐ์ด ์์ฑ
m = max(len(A), len(B))
b_sum = [0] * (m)
if len(B) > 0:
b_sum[0] = B[0]
for i in range(1, m):
b_sum[i] = b_sum[i-1] + (B[i] if i < len(B) else 0)
# A๊ฐ ์ด๊ธฐ๋ ๊ฒฝ์ฐ์ ์ ๊ณ์ฐ
count = 0
for i in range(1, len(A)):
if A[i]:
count += A[i] * b_sum[i-1]
# ์ต๋๊ฐ ๊ฐฑ์
if count > max_count:
answer = comb
max_count = count
return [x + 1 for x in answer] # 1-based๋ค๋ฅธ ํ์ด๋ฅผ ๋ ์ฐพ์๋ณด๋๊น ์ด๋ถํ์์ ์ฌ์ฉํด์๋ ํ ์ ์๋ค๊ณ ํฉ๋๋ค.
์นด์นด์ค ๊ณต์ ํด์ค ์ ๋ณด๋ฉด
- A์ B์ ์ฃผ์ฌ์๋ฅผ ํ๊บผ๋ฒ์ ๋ชจ๋ ์๋ฎฌ๋ ์ด์ ํด ์นํจ๋ฅผ ํ๋จํ๋ ๋์ , A์ B์ ์ฃผ์ฌ์๋ฅผ ๋ฐ๋ก ์๋ฎฌ๋ ์ด์ ํ๊ธฐ
- ๋์ ํฉ, ํฌ ํฌ์ธํฐ, ์ด๋ถ ํ์๋ฑ์ ๊ธฐ๋ฒ์ ์ฌ์ฉํด์ ์๊ฐ๋ณต์ก๋ ์ค์ด๊ธฐ
๊ฐ ์ด ๋ฌธ์ ์ ํต์ฌ์ธ ๊ฑฐ ๊ฐ์ต๋๋ค.
์ถ๊ฐ์๊ฒฌ
๋ฏผ์ค ๋๊ป์
"์ด ๋ฌธ์ ์์ ๊ฐ์ฅ ๋์ ์น๋ฅ ์ด๋ ๊ฒฝ๊ธฐ ํ์๋ ๋ฌด์กฐ๊ฑด ๋์ผํ๋ฏ๋ก ์น๋ฆฌ ํ์๊ฐ ๊ฐ์ฅ ๋ง๊ฑฐ๋, ์น๋ฆฌ ํ์๊ฐ ๊ฐ๋ค๋ฉด ํจ๋ฐฐ ํ์๊ฐ ๊ฐ์ฅ ์ ์ ๊ฒ์ ์๋ฏธ" ํ๋ค๊ณ ํ์ จ๋๋ฐ,
๋ฌธ์ ์์ "์น๋ฆฌํ ํ๋ฅ ์ด ๊ฐ์ฅ ๋์ ์ฃผ์ฌ์ ์กฐํฉ์ด ์ ์ผํ ๊ฒฝ์ฐ๋ง ์ฃผ์ด์ง๋๋ค." ๋ผ๊ณ ํ์ผ๋ฏ๋ก ๊ทธ๊ฒ๊น์ง๋ ๊ณ ๋ คํ ํ์๊ฐ ์์ต๋๋ค.
์ ๋ ๊ทธ๋ฅ ์น๋ฅ ์ ์น๋ฆฌํ ๊ฒฝ์ฐ์ ์ / ์ ์ฒด ๊ฒฝ์ฐ์ ์๋ผ ํด์ํ๊ณ ํ์๋๋ฐ ์น๋ฅ ์ ํด์์ด ๋ชจํธํด์ง๋ ๊ฑฐ๋ฅผ ๋ฐฉ์งํ๊ธฐ์ํด ์์ ๊ฐ์ ์กฐ๊ฑด์ ์ถ๊ฐํ ๊ฑฐ ๊ฐ์ต๋๋ค.
๋ค๋ค ๋ฌธ์ ํธ์ ๋ค๊ณ ๊ณ ์ํ์ จ์ต๋๋ค!
|
@Seol-Munhyeok ์ข์ ์ง์ ๋ค ๊ฐ์ฌํฉ๋๋ค! ์ ๊ฐ ์กฐ๊ธ ์ผ๋งค๋ก ํผ ๋๋์ด ์๊ธด ํ๋ค์. ์ ์ด ์์์ ํฌํฌ์ธํฐ๋ก ํ์ด๋ดค์ต๋๋ค. ์๊ฐ์ด 10๋ฐฐ ์ค์์ต๋๋ค. ํฌํฌ์ธํฐ๊ฐ ์ง๊ด์ ์ด๋ผ ์ดํด๊ฐ ์ฝ๋ค์. ์ฃผ์ฌ์ ๊ณ ๋ฅด๊ธฐ(ํฌํฌ์ธํฐ)#include<bits/stdc++.h>
using namespace std;
int n;
vector<vector<int>> dice;
vector<int> picked;
double maxRate = 0.0;
vector<int> maxA;
set<set<int>> s;
void getDiceSum(int idx, vector<int> v, vector<int>& sv) {
for(int i = 0; i < v.size(); i++) {
int idx = v[i];
vector<int> temp;
for(int j = 0; j < 6; j++) {
for(int k = 0; k < sv.size(); k++) {
temp.push_back(sv[k] + dice[idx][j]);
}
}
sv = move(temp);
}
}
void rollDice(vector<int> a, vector<int> b) {
vector<int> sumA = {0}; getDiceSum(0, a, sumA);
vector<int> sumB = {0}; getDiceSum(0, b, sumB);
int victoryA = 0;
int victoryB = 0;
sort(sumA.begin(), sumA.end());
sort(sumB.begin(), sumB.end());
int j = 0;
for(int i = 0; i < sumA.size(); i++) {
while(j < sumB.size() && sumA[i] > sumB[j]) {
j++;
}
victoryA += j;
}
j = 0;
for(int i = 0; i < sumB.size(); i++) {
while(j < sumA.size() && sumB[i] > sumA[j]) {
j++;
}
victoryB += j;
}
double winRateA = (double)victoryA / (sumA.size() * sumB.size());
double winRateB = (double)victoryB / (sumA.size() * sumB.size());
if(winRateA > maxRate) {
maxRate = winRateA;
maxA = a;
}
if(winRateB > maxRate) {
maxRate = winRateB;
maxA = b;
}
}
void pickDice(int cnt, int idx) {
if(cnt == n / 2) {
vector<int> a; vector<int> b;
for(int i = 0; i < n; i++) {
if(picked[i]) a.push_back(i);
else b.push_back(i);
}
set<int> as(a.begin(), a.end());
set<int> bs(b.begin(), b.end());
if(!s.count(as)) {
rollDice(a, b);
s.insert(as); s.insert(bs);
}
}
else {
for(int i = idx; i < n; i++) {
if(!picked[i]) {
picked[i] = true;
pickDice(cnt + 1, i + 1);
picked[i] = false;
}
}
}
}
vector<int> solution(vector<vector<int>> dv) {
n = dv.size();
dice = dv;
picked.resize(n, false);
pickDice(0, 0);
for(int i = 0; i < maxA.size(); i++) {
maxA[i]++;
}
return maxA;
}
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR๊ณผ ๋ฆฌ๋ทฐ๋ฅผ ๋ณด๊ธฐ ์ , ๋จผ์ ๋์ ํด๋ดค๋๋ฐ ์ ์ง์ง ๊ตฌํํ ๊ฒ๋ ๋ง๊ณ ์ด๋ ค์ ๋ค์
์ญ์ ์ ์์ง ๋ง์ด ๋ถ์กฑํ๊ฐ ๋ด
๋๋ค
์๊ทน์ผ๋ก ์๊ฐํ๊ณ ๋ ์ด์ฌํ ํด๋ด์ผ๊ฒ ์ต๋๋ค
์ ๋ 3๊ฐ์ง๋ก ๋๋ ์ ํ์์ต๋๋ค
- A๊ฐ ๊ณ ๋ฅผ ์ ์๋ ๋ชจ๋ ์กฐํฉ์ DFS๋ก ์์ฑํ๊ณ
- ๊ฐ ์กฐํฉ๋ง๋ค A/B์ ๋ชจ๋ ํฉ์ ๋ง๋ค์ด์, B ํฉ์ ์ ๋ ฌํ ๋ค A ํฉ๋ง๋ค lower_bound๋ก B < A์ธ ๊ฐ์๋งํผ ์น์๋ฅผ ํฉ์ฐํ ๋ค
- ์น์๊ฐ ์ต๋์ธ ์กฐํฉ์ ์ฑํํ๊ณ , ๋๋ฅ ์ด๋ฉด ์ฌ์ ์์ผ๋ก ๊ฐ์ฅ ๋น ๋ฅธ ์กฐํฉ์ ํํ๋ค์
์ ์ฝ๋ ๋๋ฌด ๋ณต์กํ๊ณ ๋ฉ์๋๋ ๋ง์์ ๊ทธ๋ฅ ํ๋ฆ๋ง ์ฐธ๊ณ ํ์๋ฉด ๋ ๊ฒ ๊ฐ์ต๋๋ค
์ข์ ๋ฌธ์ ๊ฐ์ ธ์์ฃผ์ ์ ๊ฐ์ฌํ๊ณ ๋ฌธ์ ํธ๋๋ผ ๊ณ ์ํ์ จ์ต๋๋ค!
์ฃผ์ฌ์ ๊ณ ๋ฅด๊ธฐ
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
static void buildSums(const vector<vector<int>>& dice, const vector<int>& idxs, vector<int>& out) {
out.clear();
out.push_back(0);
for (size_t t = 0; t < idxs.size(); t++) {
vector<int> next;
next.reserve(out.size() * 6);
const vector<int>& d = dice[idxs[t]];
for (size_t i = 0; i < out.size(); i++) {
for (size_t f = 0; f < d.size(); f++) {
next.push_back(out[i] + d[f]);
}
}
out.swap(next);
}
}
static bool lexSmaller(const vector<int>& a, const vector<int>& b) {
size_t n = a.size();
for (size_t i = 0; i < n; i++) {
if (a[i] != b[i]) {
return a[i] < b[i];
}
}
return false;
}
static void complementIndices(int n, const vector<int>& pick, vector<int>& rest) {
rest.clear();
vector<char> used(n, 0);
for (size_t i = 0; i < pick.size(); i++) {
used[pick[i]] = 1;
}
for (int i = 0; i < n; i++) {
if (!used[i]) {
rest.push_back(i);
}
}
}
vector<int> solution(vector<vector<int>> dice) {
int n = static_cast<int>(dice.size());
int half = n / 2;
vector<int> bestChoice;
long long bestWin = -1;
vector<int> comb;
comb.reserve(half);
vector<int> aIdx, bIdx;
vector<int> aSums, bSums;
function<void(int,int)> dfs = [&](int start, int need) {
if (need == 0) {
aIdx = comb;
complementIndices(n, aIdx, bIdx);
buildSums(dice, aIdx, aSums);
buildSums(dice, bIdx, bSums);
sort(bSums.begin(), bSums.end());
long long win = 0;
for (size_t i = 0; i < aSums.size(); i++) {
int x = aSums[i];
auto it = lower_bound(bSums.begin(), bSums.end(), x);
win += static_cast<long long>(it - bSums.begin());
}
if (win > bestWin) {
bestWin = win;
bestChoice = aIdx;
} else if (win == bestWin) {
if (lexSmaller(aIdx, bestChoice)) {
bestChoice = aIdx;
}
}
return;
}
for (int i = start; i <= n - need; i++) {
comb.push_back(i);
dfs(i + 1, need - 1);
comb.pop_back();
}
};
dfs(0, half);
vector<int> answer;
answer.reserve(half);
for (size_t i = 0; i < bestChoice.size(); i++) {
answer.push_back(bestChoice[i] + 1);
}
return answer;
}

๐ ๋ฌธ์ ๋งํฌ
์ฃผ์ฌ์ ๊ณ ๋ฅด๊ธฐ
https://school.programmers.co.kr/learn/courses/30/lessons/258709
โ๏ธ ์์๋ ์๊ฐ
1์๊ฐ
์ฌ๋ด
โจ ์๋ ์ฝ๋
A์ B๊ฐ n๊ฐ์ ์ฃผ์ฌ์ ์ค์ n / 2๊ฐ์ ์ฃผ์ฌ์๋ฅผ ๊ฐ๊ฐ ๊ณจ๋ผ์ ๋ชจ๋ ๊ฒฝ์ฐ์ ์๋ฅผ ๋น๊ตํด ์น๋ฅ ์ ๊ณ์ฐํ์ฌ ๊ฐ์ฅ ์น๋ฅ ์ด ๋์ ์ฃผ์ฌ์ ์กฐํฉ์ ๊ตฌํด์ผํ๋ ๋ฌธ์ ์ ๋๋ค. ์ด๋ ์กฐํฉ์ ๊ตฌํํ์ฌ ๋น๊ตํด๋ณผํ ๋ฐ ์ค์ ๋ก ๋๊ฐ ์น๋ฅ ์ด ๋์๋ ์ค์ํ์ง ์์ต๋๋ค. ๋น์ฐํ A๋๋ B๊ฐ ์น๋ฅ ์ด ๋์ ๊ฒ์ด๊ณ ์ฐ๋ฆฌ๋ ๊ฐ์ฅ ์น๋ฅ ์ด ๋์ ์กฐํฉ์ ๊ตฌํ๊ธฐ๋ง ํ๋ฉด ๋ฉ๋๋ค.
์ฒ์์๋ ์ฃผ์ฌ์ ํ์น์กฐํฉ์ ๊ตฌํ ๋ ค๋ฉด ์ฃผ์ฌ์ ํฉ๋ค์ ํ๊ท ์ ๋น๊ตํด์ผ ํ ๊น๋ ์๊ฐํด๋ดค๋๋ฐ ๊ทธ๋ฐ์์ผ๋ก ์ต์ ํํ๋ ๋ฌธ์ ๋ ์ฌํ๊น์ง ๋ง์ด ์์๋ ๊ฒ ๊ฐ๊ณ , ๋น์ฐํ ๋ชจ๋ ์ฃผ์ฌ์ ์กฐํฉ์ ๋ฐ๋ฅธ ์น๋ถ์ ๊ฒฝ์ฐ์ ์๋ฅผ ๊ตฌํด์ผํ ๊ฒ ๊ฐ์์ต๋๋ค. ์ต์ ์ ๊ฒฝ์ฐ ์ฃผ์ฌ์๊ฐ 10๊ฐ์ผ ๋ 10C5 * 6^5์ ๋์ ์๊ฐ๋ณต์ก๋๊ฐ ๋์ฌ ๊ฒ ๊ฐ์๊ณ ์ง์ ๊ณ์ฐํด๋ณด์ง๋ ์์์ง๋ง ๋ค๋ฅธ ํ์ด ๋ฐฉ๋ฒ๋ ๋ ์ค๋ฅด์ง ์์ ํ์ด์ ๋ค์ด๊ฐ์ต๋๋ค.
์ฐ์ n / 2๊ฐ์ฉ ์ฃผ์ฌ์๋ฅผ ๋๋ ๊ฐ์ง๋ ๋ชจ๋ ์กฐํฉ์ ๊ตฌํ๋ pickDice ํจ์๋ฅผ ๋ง๋ค์์ต๋๋ค. ์ด๋ ์กฐํฉ์ ์ฌ๊ทํจ์๋ฅผ ์ด์ฉํ๊ณ ํ ๋ฒ ์ฌ์ฉํ๋ ์กฐํฉ๋ค์ ๋ค์ ์ฌ์ฉํ์ง ์๊ธฐ ์ํด Set<Set>๋ฅผ ๋ง๋ค์ด ์ค๋ณต์ ๋ฐฉ์งํ์ต๋๋ค. ์ ๋ฒ์ ์์ ๋ฒ์ฃ ๋ฌธ์ ์์ set<tuple<int, int, int>>๋ฅผ ์ฌ์ฉํ์๋๋ฐ Set<Set>๋ฅผ ์ฌ์ฉํ๋ฉด ์ฌ๋งํ ๋ฌธ์ ์์ DFS + ๋ฉ๋ชจ์ด์ ์ด์ ์ด ํ์ํ ๋ ์ฌ์ฉํ ์ ์์ ๊ฒ ๊ฐ์ต๋๋ค.
์ฃผ์ฌ์๋ฅผ ๊ฐ์ ๋๋ ๊ฐ์ง๊ณ ๋ชจ๋ ํฉ๋ค์ ๊ตฌํด์ผํ ํ ๋ฐ getDiceSum() ์ฌ๊ทํจ์๋ฅผ ํตํด ๋ชจ๋ ํฉ๋ค์ ๊ฐ๊ฐ ๋ฐฐ์ด(sumA, sumB)์ ์ ์ฅํ์ต๋๋ค. ์ด๋ sumA ๋ฐ sumB๋ฅผ ์ ๋ ๋งค๊ฐ๋ณ์ ์ฐธ์กฐ๋ฅผ ํตํด ์ ์ญ๋ณ์๋ฅผ ์ฌ์ฉํ์ง ์๊ณ ํฉ๋ค์ ์ ์ฅํ ์ ์์์ต๋๋ค.
์ด์ ์ฃผ์ฌ์์ ์กฐํฉ์ ๋ฐ๋ฅธ ๋ชจ๋ ํฉ๋ ๊ตฌํด์ก์ผ๋ฏ๋ก ๋ชจ๋ ๊ฐ์ ๊ฐ๊ฐ ๋น๊ตํด์ ์น๋ฆฌ ํ์ ์ ํจ๋ฐฐ ํ์๋ฅผ ๊ตฌํฉ๋๋ค. ์ด ๋ฌธ์ ์์ ๊ฐ์ฅ ๋์ ์น๋ฅ ์ด๋ ๊ฒฝ๊ธฐ ํ์๋ ๋ฌด์กฐ๊ฑด ๋์ผํ๋ฏ๋ก ์น๋ฆฌ ํ์๊ฐ ๊ฐ์ฅ ๋ง๊ฑฐ๋, ์น๋ฆฌ ํ์๊ฐ ๊ฐ๋ค๋ฉด ํจ๋ฐฐ ํ์๊ฐ ๊ฐ์ฅ ์ ์ ๊ฒ์ ์๋ฏธํ๋ฏ๋ก ์น๋ฆฌ ํ์์ ํจ๋ฐฐ ํ์๋ฅผ ๋ชจ๋ ๊ตฌํฉ๋๋ค. ์ ๋ maxRate๋ผ๋ pair<int, int> ๋ณ์๋ฅผ ๋ง๋ค์ด์ ๊ฐ๊ฐ ์น๋ฆฌ์ ํจ๋ฐฐ์๋ฅผ ๋น๊ตํ์ฌ ์ต๊ณ ์ ์น๋ฅ ์ ๋ฐ๋ฅธ ์น๋ฆฌ ์์ ํจ๋ฐฐ์ ๊ฐ์ ๊ฐฑ์ ํด์ฃผ์์ต๋๋ค. ๊ฐ์ ๊ฐฑ์ ํด์ฃผ๋ฉด์ ์ด ๋ฌธ์ ์ ๋ต์ธ A๊ฐ ์น๋ฅ ์ด ๊ฐ์ฅ ๋์ ์ฃผ์ฌ์ ์กฐํฉ maxA๋ ๊ฐฑ์ ํด์ฃผ์์ต๋๋ค.
์ฌ๋ด
๐ ์๋กญ๊ฒ ์๊ฒ๋ ๋ด์ฉ