pair 써서 구하면 될 것 같았다. 하나는 점수 저장하고 하나는 사람 번호 저장해서 정렬하면 끝~
점수를 먼저 정렬해야 하니 점수를 xx로 두고 정렬했다. 문제가 있다면 번호는 작은 순서대로 정렬해야 하는데 오름차순으로 하면 번호가 큰 사람이 먼저 나온다. 그래서 번호를 -1 곱해서 저장한 다음 마지막에 -1 다시 곱해서 출력하는 방식으로 구현했다. 이전에 북님 이렇게 한 거 보고 기발하다 생각했는데 이렇게 써먹네ㅋㅋㅋ 덕분에 쉽게 풀었다.
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <functional>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
#include <bitset>
#define xx first
#define yy second
#define all(x) (x).begin(), (x).end()
using namespace std;
using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;
using iii = tuple<int, int, int>;
int main()
{
int n, m;
scanf("%d %d", &n, &m);
vector<int> point(n);
for (int i = 0; i < n; i++)
scanf("%d", &point[i]);
vector<ii> v(m);
for (int i = 0; i < m; i++)
{
scanf("%d", &v[i].yy);
v[i].yy *= -1;
for (int j = 0; j < n; j++)
{
string s;
cin >> s;
if (s == "X")
continue;
v[i].xx += point[j];
}
}
sort(all(v), greater<>());
printf("%d %d\n", v[0].yy * -1, v[0].xx);
return 0;
}
'prompt' 카테고리의 다른 글
[토요라운드] E. 컴백홈 (1189) (0) | 2020.12.07 |
---|---|
[토요라운드] D. 에너지 드링크 (20115) (0) | 2020.12.07 |
[토요라운드] B. 2의 제곱수 계산하기 (19946) (0) | 2020.12.07 |
[토요라운드] A. 폰 노이만과 파리 (14924) (0) | 2020.12.07 |
[토요라운드] 20/12/05 후기 (0) | 2020.12.07 |