C#/알고리즘
백준# 7569 - 덩치
McRobbin
2020. 5. 13. 18:21
https://www.acmicpc.net/problem/7568
7568번: 덩치
우리는 사람의 덩치를 키와 몸무게, 이 두 개의 값으로 표현하여 그 등수를 매겨보려고 한다. 어떤 사람의 몸무게가 x kg이고 키가 y cm라면 이 사람의 덩치는 (x,y)로 표시된다. 두 사람 A 와 B의 덩�
www.acmicpc.net
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
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _1914
{
class Program
{
public class Body
{
public int weight;
public int height;
public int bigger;
public Body(int weight, int height)
{
this.weight = weight;
this.height = height;
this.bigger = 0;
}
}
static void Main(string[] args)
{
int count = int.Parse(Console.ReadLine());
var bodyList = new List<Body>();
for(int i = 0; i < count; i++)
{
int[] input = Console.ReadLine().Split(' ')
.Select(x => int.Parse(x)).ToArray();
bodyList.Add(new Body(input[0], input[1]));
}
bodyList.ForEach(x => x.bigger
= bodyList.FindAll(y => y.height > x.height && y.weight > x.weight).Count);
foreach (var b in bodyList)
Console.Write(b.bigger + 1 + " ");
}
}
}
|
cs |
본인보다 키와 덩치가 큰 사람이 몇명인지 구하면 되겠습니다.