C# 7568번 덩치
2022. 1. 10. 13:22ㆍ코딩테스트 문제 풀이/[백준] 브루트 포스
728x90
반응형
코드 :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _3
{
class Program
{
static void Main(string[] args)
{
int N = Convert.ToInt32(Console.ReadLine());
int[] h = new int[N];
int[] w = new int[N];
StringBuilder sb = new StringBuilder();
for (int i = 0; i < N; i++)
{
string input = Console.ReadLine();
string[] inputdata = input.Split(' ');
w[i] = Convert.ToInt32(inputdata[0]);
h[i] = Convert.ToInt32(inputdata[1]);
} //몸무게, 키 배열정렬
for (int i = 0; i < N; i++)
{
int count = 0;
for (int j = 0; j < N; j++)
{
if(h[i] < h[j] && w[i] < w[j])
{
count += 1;
}
}
sb.AppendFormat("{0} ", count+1);
}
Console.WriteLine(sb);
}
}
}
코드 풀이 :
키와 몸무게, 둘 다 큰 순위를 만드는 문제이다.
예제1에서 55 185의 경우 몸무게와 키가 모두 큰 경우는 88 186 하나 밖에 없다.
46 155의 경우 키와 몸무게가 모두 큰 경우는 4가지이다
즉 count + 1 을 출력
깃허브 :
https://github.com/CheongHo-Lee/Algorithm-Study
GitHub - CheongHo-Lee/Algorithm-Study: Algorithm Study For Coding Test
Algorithm Study For Coding Test. Contribute to CheongHo-Lee/Algorithm-Study development by creating an account on GitHub.
github.com
728x90
반응형
'코딩테스트 문제 풀이 > [백준] 브루트 포스' 카테고리의 다른 글
C# 1436번 영화감독 숌 (0) | 2022.01.10 |
---|---|
C# 1018번 체스판 다시 칠하기 (0) | 2022.01.10 |
C# 2231번 분해합 (0) | 2022.01.10 |
C# 2798번 블랙잭 (0) | 2022.01.10 |