编程介的小学生 2017-08-23 03:08 采纳率: 20.5%
浏览 739
已采纳

Unrequited Love

Owen had been through unrequited love with N MM for a long time. In order to celebrate the 8th anniversary of ZOJ, he decided to "watch white".

One night, MMs are sitting in a ring. Owen's plan is to give them love letters secretly so that MMs who receive letters will know that Owen loves them. Besides, each MM has a "happy point". The greater it is, the happier Owen will be if that MM receives his love letter.

One more problem. MM is very sensitive, so she will know if Owen (even secretly) drops a letter to the girl next to her. Meanwhile, MM is likely to be jealous. If she receives the love letter and finds that some other girl also gets a love letter, she will pia Owen to death.

Owen, as a smart boy, won't let MM pia him, and decides to program to calculate the maximum sum of happy points he can get. However, love is blind. Poor Owen has lost the ability to program. So he turns to you.

Input

There are no more than 10 test cases.
Each test case begins with an integer N (1 <= N <= 1000000).
Then followed N integers(0<= Ni <= 1000), each representing a happy point for one MM. The first and last MM sit next to each other, forming a ring.
Each test case occupies one line.
Output

One line for each test case.
An interger for each line indicating the maximum sun of happy points Owen can get.
Sample Input

5 1 2 3 4 5
6 1 2 3 4 5 6
Sample Output

8
12

  • 写回答

2条回答 默认 最新

  • threenewbee 2017-08-27 14:52
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)