Teams Formation CodeForces
来源:互联网 发布:国内域名不备案 编辑:程序博客网 时间:2024/05/01 20:02
This time the Berland Team Olympiad in Informatics is held in a remote city that can only be reached by one small bus. Bus hasn passenger seats, seati can be occupied only by a participant from the cityai.
Today the bus has completed m trips, each time bringingn participants. The participants were then aligned in one line in the order they arrived, with people from the same bus standing in the order of their seats (i. e. if we write down the cities where the participants came from, we get the sequencea1, a2, ..., an repeatedm times).
After that some teams were formed, each consisting of k participants form the same city standing next to each other in the line. Once formed, teams left the line. The teams were formed until there were nok neighboring participants from the same city.
Help the organizers determine how many participants have left in the line after that process ended. We can prove that answer doesn't depend on the order in which teams were selected.
The first line contains three integers n, k andm (1 ≤ n ≤ 105,2 ≤ k ≤ 109,1 ≤ m ≤ 109).
The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 105), where ai is the number of city, person from which must take seati in the bus.
Output the number of remaining participants in the line.
4 2 51 2 3 1
12
1 9 101
1
3 2 101 2 1
0
In the second example, the line consists of ten participants from the same city. Nine of them will form a team. At the end, only one participant will stay in the line.
- codeforces D.Teams Formation
- Teams Formation CodeForces
- codeforces 878B B. Teams Formation 模拟
- Codeforces Round #443 (Div. 2)D. Teams Formation详解
- Codeforces Round #443 (Div. 2) D. Teams Formation
- Codeforces Round #443 (Div. 2) D. Teams Formation
- CF878B Teams Formation
- 【CODEFORCES】 B. Random Teams
- codeforces 216B-Forming Teams
- Codeforces 432A Choosing Teams
- Codeforces 432 A. Choosing Teams
- codeforces-#478B. Random Teams
- Codeforces 478B. Random Teams
- Codeforces 478B Random Teams
- Codeforces Round#478--Random Teams
- Random Teams(Codeforces Round 273)
- Codeforces 478B Random Teams
- Codeforces 432A Choosing Teams
- 帧动画通用更新代码
- 求解ax===b(mod m)的特解和[0,m)的所有解
- Windows 启动服务命令大全
- 理解I/O:随机和顺序
- js获取get请求后面的参数列表
- Teams Formation CodeForces
- 关于pyhon3的yield关键字的一点学习
- Maven 打包命令(1)
- JS学习指南
- Linux 内存管理
- VS2015永久配置OPENCV3.0
- 位字段
- Spring事务的传播特性
- 在嵌入式uClibc上移植valgrind