QOJ.ac

QOJ

時間限制: 1.0 s 記憶體限制: 2048 MB 總分: 100

#15948. A Little Leftover Pizza

统计

计算机系刚刚举办了一场大型派对,并订购了太多的比萨。现在是时候把剩菜收起来了。他们订购了若干个小号(small)、中号(medium)和大号(large)比萨,其中部分或全部比萨盒中仍有剩余的比萨饼块。一个小号比萨有 6 块,一个中号比萨有 8 块,一个大号比萨有 12 块。为了节省空间,你可以将相同尺寸比萨的剩余饼块合并到对应尺寸的盒子中,但你不能将某块比萨放入不同尺寸的盒子中,也不能在一个盒子中放入超过其原本容量的比萨饼块。要装下所有的剩余比萨,最少需要多少个盒子?

输入格式

输入的第一行包含一个正整数 $n$ ($n < 1000$),表示订购的比萨数量。

接下来的 $n$ 行,每行包含两个由空格隔开的项 $s_i$ 和 $l_i$,代表某特定比萨的剩余情况。$s_i$ 是字符串 SML 之一,代表比萨 $i$ 的尺寸;$l_i$ 是一个整数,代表比萨 $i$ 剩余的饼块数。你可以认为每个 $l_i$ 都在 $0$ 到该尺寸比萨原本的总块数(含)之间。

输出格式

输出一个整数,表示在满足上述约束条件的情况下,装下所有剩余比萨所需的最少盒子总数。

样例

输入样例 1

3
S 0
M 5
L 0

输出样例 1

1

输入样例 2

3
S 3
S 4
S 2

输出样例 2

2

输入样例 3

4
S 1
M 1
M 3
L 1

输出样例 3

3

输入样例 4

4
L 6
M 2
M 6
L 6

输出样例 4

2

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.