编程介的小学生 2016-12-19 11:21 采纳率: 20.5%
浏览 861
已采纳

Cutting Necklace

Description

Today is Valentine's Day. Gnaf Ynot is going to present a beautiful necklace to his girl friend Mxxjx. He has bought a necklace of pearls some time ago. The necklace consists of many sheeny pearls and is very pretty. However, the necklace is too long for his girl friend. So Gnaf Ynot has to cut a slice from the necklace so that he can get a shorter one. He wants that the cut slice of necklace can be as evenly bright as possible, i.e. the average brightness of the slice should be maximized. Gnaf Ynot requests your help.

The necklace is in the form of a ring of pearls. Each pearl has a brightness. Your task is to cut a substring of pearls from the ring, so that the substring has the largest average brightness of pearls. The substring you cut should not be too long or too short as well. To help Gnaf Ynot making Mxxjx happy, please try your best to solve this problem!
Input

Input contains multiple test cases. Each test case starts a line containing three numbers N, L, U (1 <= L <= U <= N <= 1000000), which are the number of pearls of the necklace, the permitted shortest length and the longest length of the cut slice. Then the following line gives the brightness of each pearl (the value of brightness are integers and in the range of [-1000, 1000]).
Output

For each test case print the largest average brightness of the slice you cut from the necklace in one line. The result should be represented using fraction form such as A/B (here A and B are integers, B > 0 and (A, B) = 1).
Sample Input

4 2 3
4 -1 3 1
4 2 2
4 -1 3 1
Sample Output

8/3
5/2

  • 写回答

1条回答 默认 最新

  • devmiao 2016-12-19 16:43
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line