딱히 어렵지 않은 문제다.
문제의 조건만 잘 이해 한다면 쉬운문제다. 가장 Bi이하중 큰 종목이 아니라 가장 앞의 종목인것을 유의해서 풀면 된다.
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(int argc, char** argv)
{
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int test_case;
int T;
cin >> T;
for (test_case = 1; test_case <= T; ++test_case)
{
int N, M; cin >> N >> M;
vector<int> A(N);
vector<int> B(M);
vector<int> voted(N, 0);
for (int i = 0; i < N; i++) cin >> A[i];
for (int i = 0; i < M; i++) cin >> B[i];
for (int i = 0; i < M; i++)
{
int max_A = 0;
int index = 0;
for (int j = 0; j < N; j++)
if (A[j] <= B[i])
{
index = j;
break;
}
voted[index]++;
}
int out = max_element(voted.begin(), voted.end()) - voted.begin();
cout << '#' << test_case << ' ' << out + 1<< '\n';
}
return 0;
}
'Coding_Test 연습 > SWEA' 카테고리의 다른 글
[SWEA] (C++) D4 4613 러시아 국기 같은 깃발 (0) | 2022.04.13 |
---|---|
[SWEA] (C++) D4 7854 최약수 (0) | 2022.04.13 |
[SWEA] (C++) D4 1494 사랑의 카운슬러 (0) | 2022.04.13 |
[SWEA] (C++) D4 6719 성수의 프로그래밍 강좌 시청 (0) | 2022.04.12 |
[SWEA] (C++) D4 3316 동아리실 관리하기 (0) | 2022.04.12 |