-
Notifications
You must be signed in to change notification settings - Fork 0
/
prob_c.cs
36 lines (34 loc) · 986 Bytes
/
prob_c.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Solution
{
class Solution
{
static void Main(string[] args)
{
int length = int.Parse(Console.ReadLine());
List<int> stacks = new List<int>();
for (int i = 0; i < length; i++)
{
int box = int.Parse(Console.ReadLine());
int index = -1;
for (int j = 0; j < stacks.Count; j++)
{
if (stacks[j] >= box)
{
if (index == -1) index = j;
else
{
if (stacks[j] < stacks[index]) index = j;
}
}
}
if (index == -1) stacks.Add(box);
else stacks[index] = box;
}
Console.WriteLine(stacks.Count);
}
}
}