반응형
SMALL
문제

풀이
using System;
using System.Collections.Generic;
using System.IO;
namespace BOJ_11945
{
internal class Program
{
static void Main(string[] args)
{
StreamWriter sw = new StreamWriter(Console.OpenStandardOutput());
StreamReader sr = new StreamReader(Console.OpenStandardInput());
int N = int.Parse(sr.ReadLine());
int[] 번호표 = Array.ConvertAll(sr.ReadLine().Split(), int.Parse);
List<int> lines = new List<int>();
int student = 1;
for (int i = 0; i < N; i++)
{
if (i == 0)
{
lines.Add(student);
student++;
}
else
{
lines.Insert(번호표[i], student);
student++;
}
}
lines.Reverse();
foreach (int line in lines) { sw.Write("{0} ", line); }
sr.Close();
sw.Close();
}
}
}
결과창

제너릭 리스트의 insert 메서드 를 활용할수 있는 좋은 기본 예시였다. (Reverse 메서드는 덤)
반응형
LIST
'Algorithm > BOJ' 카테고리의 다른 글
| [BOJ] 1297번 TV 크기 C# 사용 풀이 (0) | 2023.02.08 |
|---|---|
| [BOJ] 2581번 소수 C# 사용 풀이 (0) | 2023.02.06 |
| [BOJ] 5524번 입실 관리 C# 문제 풀이 (0) | 2023.02.05 |
| [BOJ]11945번 뜨거운 붕어빵 C# 사용 풀이 (0) | 2023.02.05 |
| [BOJ] 4796번 캠핑 C#사용 알고리즘 풀이 (0) | 2023.02.04 |