강의로 돌아가기

### 8, 9, 11 번 에서 틀리는데 뭐가 잘못됬을까요?

반례를 뭐로 해야할지 모르겠네요 ㅠㅠ

###### 작성중인 코드―solution.cpp
``````1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>

using namespace std;

int mysort(pair<string, int> a, pair<string, int> b);

vector<int> solution(vector<string> g, vector<int> p)
{
vector<vector<int>> pla;
vector<pair<string, int>> gen;
vector<int> ind;
pair<string, int> fge;
int j = 0;

for(int i = 0; i < g.size(); i++)
{
if(!(gen.empty()))
{
for(j = 0; j < gen.size(); j++)
{
if(gen[j].first.compare(g[i]) == 0)
{
break;
}
}
}

if(j == gen.size())
{
fge = make_pair(g[i], 0);
gen.push_back(fge);
pla[j].push_back(p[i]);
gen[j].second += p[i];
}
else
{
pla[j].push_back(p[i]);
gen[j].second += p[i];
}
}

for(int i = 0; i < pla.size(); i++)
{
sort(pla[i].begin(), pla[i].end(), greater<int>());
ind.push_back(gen[i].second);
}

sort(gen.begin(), gen.end(), mysort);

for(int i = 0; i < pla.size(); i++)
{
for(j = 0; j < ind.size(); j++)
{
if(ind[j] == gen[i].second)
{
break;
}
}

for(int k = 0; k < p.size(); k++)
{
if(p[k] == pla[j][0] && g[k].compare(gen[i].first) == 0)
{
break;
}
}

if(pla[i].size() != 1)
{
for(int k = 0; k < p.size(); k++)
{
if(p[k] == pla[j][1] && g[k].compare(gen[i].first) == 0 && answer[answer.size() - 1] != k)
{
break;
}
}
}
}