반응형
    
    
    
  문제 출처 :
https://www.acmicpc.net/problem/10814
알고리즘 분석 :
문제 해결에 필요한 사항
1. 정렬
정렬을 이용해서 풀어도 되는 문제이지만, 나이가 200보다 작거나 같다는 조건이 있으므로
나이 벡터를 만들어서 문제를 풀어도 해결이 가능하다.
소스 코드 :
| 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 <cstdio> #include <string> using namespace std; int main() {     vector<string> vc[203];     int n;     int age;     char name[101];     string str;     scanf("%d",&n);     for (int i = 0; i < n; i++)     {         scanf("%d %s", &age, name);                 vc[age].push_back(name);     }     for (int i = 0; i <= 200; i++)         if (vc[i].size())                 for (int j = 0; j < vc[i].size(); j++)                 printf("%d %s\n", i, vc[i][j].c_str());             return 0; } //                                                       This source code Copyright belongs to Crocus //                                                        If you want to see more? click here >> | Crocus | 
반응형
    
    
    
  'Applied > 알고리즘 문제풀이' 카테고리의 다른 글
| [11266번] 단절점 (0) | 2018.02.21 | 
|---|---|
| [2792번] 보석 상자 (2) | 2018.02.21 | 
| [14927번] 전구 끄기 (0) | 2018.02.19 | 
| [14925번] 목장 건설하기 (0) | 2018.02.19 | 
| [11651번] 좌표 정렬하기 2 (0) | 2018.02.19 |