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 | #include<cstdio> #include<vector> #include<algorithm> using namespace std; vector<pair<int,pair<int,int>>> v; int n,a,b,cnt; void func(){ for(int i=0; i<n; i++){ for(int j=0; j<n; j++){ if(i==j) continue; if(v[i].second.first<v[j].second.first && v[i].second.second<v[j].second.second){ v[i].first++; } } } } int main(void){ scanf("%d", &n); for(int i=0; i<n; i++){ scanf("%d %d", &a, &b); v.push_back(make_pair(1,make_pair(a,b))); } func(); for(int i=0; i<n; i++) printf("%d\n", v[i].first); return 0; } | cs |
- JAVA
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 | import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.IOException; import java.util.StringTokenizer; public class Main{ public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringBuffer sb = new StringBuffer(); int n = Integer.parseInt(br.readLine()); int[][] arr = new int[n][2]; for(int i=0; i<n; i++){ String str = br.readLine(); StringTokenizer st = new StringTokenizer(str," "); arr[i][0]=Integer.parseInt(st.nextToken()); arr[i][1]=Integer.parseInt(st.nextToken()); } for(int i=0; i<n; i++){ int ans=1; for(int j=0; j<n; j++){ if(i==j) continue; if(arr[i][0]<arr[j][0] && arr[i][1]<arr[j][1]) ans++; } sb.append(ans).append(" "); } System.out.print(sb); } } | cs |
'백준 2 > 완전탐색' 카테고리의 다른 글
| [백준 17142] 연구소3 (0) | 2020.12.08 |
|---|---|
| [백준 14225] 부분수열의 합 (0) | 2020.12.07 |
| [백준 1018] 체스판 칠하기 (C++/Python) (0) | 2020.12.07 |
| [백준 3085] 사탕게임 (C++) (0) | 2020.12.07 |
| [백준 10448] 유레카 이론 (C++) (0) | 2020.12.07 |