ICPC Miền Trung 2018-2019 - Bài D: Colored Balloons
Đề bài
D. Colored Balloons
Standard I/O | Time Limit: 1s | Memory Limit: 256 MB
(Python on oj.vietnamson.com: 2s)
Hung wants to celebrate his wife's birthday so he decided to decorate his room with the colored balloons. Hung has n colored balloons that are colored with k different colors. The colors are labeled from 1 to k. Balloons of the same color are indistinguishable. He will arrange all the balloons in the line so the last balloons of color i before the last balloons of color i + 1 for all i from 1 to k - 1. Now he wonders how many different ways this can happen.
Input
The first line of input will have one integer k $(1 \le k \le 1000)$ the number of colors.
Then, k lines will follow. The i-th line will contain $a_i$, the number of balloons of the i-th color $(1 \le c_i \le 1000)$. The total number of balloons doesn't exceed 1000.
Output
A single integer, the number of ways that Hung can arrange all the balloons as described in the statement, modulo 1 000 000 007.
Note
In the first sample, we have 1 balloons of color 1, 3 balloons of color 2. The three ways for Hung are:
1222
2122
2212Note (VIETNAMSON)
- Problem of the 2018 ACM-ICPC Vietnam Central Provincial Programming Contest (hosted by University of Science and Technology - The University of Danang). The statement and samples are kept verbatim from the original PDF. There are no official test data; the tests on oj.vietnamson.com were made by VIETNAMSON and checked against an independent brute-force solution (the samples are printed in one table there; here they are split).
- "$1 \le c_i \le 1000$" in the statement means $1 \le a_i \le 1000$.
- The original PDF does not state time/memory limits; oj.vietnamson.com uses the limits above.
- Python on oj.vietnamson.com: time limit 2 s, memory limit 1 GB.
Input
2
1
3
Output
3Input
3
1
2
3
Output
20Ý tưởng và lời giải chi tiết
Phần phân tích ý tưởng, các cách giải từ cơ bản đến tối ưu kèm code C++/Python và chấm thử trên VIETNAMSON OJ dành cho học viên đã đăng ký gói.
- Không biết học gì trước, học gì sau, học lan man nên kiến thức bị hổng.
- Bí bài không ai gỡ, ngồi cả buổi vẫn không ra rồi bỏ cuộc.
- Code chạy được nhưng không đủ điểm, không biết sai ở đâu, chậm ở đâu.
- Không có đề thi thử và người chấm, nên không biết mình đang ở mức nào.
- Dễ nản giữa chừng khi không có ai theo sát.
- Lộ trình 111 buổi video sắp sẵn từ dòng code đầu tiên đến đề HSG thật của các tỉnh.
- Thầy trực tiếp gỡ bí, chữa bài cho từng em qua nhóm Zalo riêng.
- Hệ thống chấm bài tự động 24/7 và thi thử HSG hằng tuần để biết chính xác mình đang ở đâu.
- Đóng học phí một lần, thầy kèm lâu dài: từ thi chuyên Tin đến HSG quốc gia và cả khi lên đại học.
