본문 바로가기

ProgramSoliving

백준 : 7568

반응형

 

 

https://www.acmicpc.net/problem/7568

 

7568번: 덩치

우리는 사람의 덩치를 키와 몸무게, 이 두 개의 값으로 표현하여 그 등수를 매겨보려고 한다. 어떤 사람의 몸무게가 x kg이고 키가 y cm라면 이 사람의 덩치는 (x,y)로 표시된다. 두 사람 A 와 B의 덩치가 각각 (x,y), (p,q)라고 할 때 x>p 그리고 y>q 이라면 우리는 A의 덩치가 B의 덩치보다 "더 크다"고 말한다. 예를 들어 어떤 A, B 두 사람의 덩치가 각각 (56,177), (45,165) 라고 한다면 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
#include<iostream>
#include<vector>
#include<algorithm>
 
using namespace std;;
int N;
 
int Solve(vector <pair<intint>> v, int con) {
    int rank = 0;
 
    for (int i = 0;i < N;i++)
    {
        if (i == con) continue;
 
        if (v[i].first > v[con].first && v[i].second > v[con].second) ++rank;
    }
    return rank + 1;
}
 
int main(void) {
 
    vector <pair<intint>> v;
    pair<intint> tmp;
    cin >> N;
    for (int i = 0;i < N;i++) {
        cin >> tmp.first >> tmp.second;
        v.push_back(tmp);
    }
 
    for (int i = 0;i < N;i++)
    {
        cout << Solve(v,i) << " ";
    }
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
반응형

'ProgramSoliving' 카테고리의 다른 글

백준 : 2606  (0) 2019.12.16
백준 : 1436  (0) 2019.12.16
백준 : 1018  (0) 2019.12.15
백준 : 2231  (0) 2019.12.13
백준 : 2798  (0) 2019.12.13