CF1358D.The Best Vacation
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You've been in love with Coronavirus-chan for a long time, but you didn't know where she lived until now. And just now you found out that she lives in a faraway place called Naha.
You immediately decided to take a vacation and visit Coronavirus-chan. Your vacation lasts exactly x days and that's the exact number of days you will spend visiting your friend. You will spend exactly x consecutive (successive) days visiting Coronavirus-chan.
They use a very unusual calendar in Naha: there are n months in a year, i-th month lasts exactly di days. Days in the i-th month are numbered from 1 to di. There are no leap years in Naha.
The mood of Coronavirus-chan (and, accordingly, her desire to hug you) depends on the number of the day in a month. In particular, you get j hugs if you visit Coronavirus-chan on the j-th day of the month.
You know about this feature of your friend and want to plan your trip to get as many hugs as possible (and then maybe you can win the heart of Coronavirus-chan).
Please note that your trip should not necessarily begin and end in the same year.
你早已爱上了冠状病毒酱(Coronavirus-chan),但直到现在才知道她住在遥远的那霸(Naha)。
你立刻决定休假,并去拜访冠状病毒酱。你的假期恰好持续 x 天,而这 x 天将全部用于拜访你的朋友。你将连续(即逐日相连)地拜访冠状病毒酱,共 x 天。
那霸使用一种非常特殊的日历:一年有 n 个月,第 i 个月恰好持续 di 天。第 i 个月的日期编号为 1 至 di。那霸没有闰年。
冠状病毒酱的心情(以及相应地,她想拥抱你的愿望)取决于当月的日期编号。具体来说,如果你在某个月的第 j 天拜访她,你将获得 j 次拥抱。
你早已知晓朋友的这一特点,因此希望规划行程,以获得尽可能多的拥抱(也许这样你就能赢得冠状病毒酱的芳心)。
请注意,你的旅行不一定必须在同一年内开始和结束。
输入格式
The first line of input contains two integers n and x (1≤n≤2⋅105) — the number of months in the year and the number of days you can spend with your friend.
The second line contains n integers d1,d2,…,dn, di is the number of days in the i-th month (1≤di≤106).
It is guaranteed that 1≤x≤d1+d2+…+dn.
输入的第一行包含两个整数 n 和 x(1≤n≤2⋅105)—— 分别表示一年中的月份数和你可以与朋友共度的天数。
第二行包含 n 个整数 d1,d2,…,dn,其中 di 表示第 i 个月的天数(1≤di≤106)。
保证 1≤x≤d1+d2+…+dn。
输出格式
Print one integer — the maximum number of hugs that you can get from Coronavirus-chan during the best vacation in your life.
输出一个整数——你在人生中最棒的假期中能从 Coronavirus-chan 那里获得的最大拥抱次数。
输入输出样例
输入#1
3 2 1 3 1
输出#1
5
输入#2
3 6 3 3 3
输出#2
12
输入#3
5 6 4 2 3 1 3
输出#3
15
说明/提示
In the first test case, the numbers of the days in a year are (indices of days in a corresponding month) 1,1,2,3,1. Coronavirus-chan will hug you the most if you come on the third day of the year: 2+3=5 hugs.
In the second test case, the numbers of the days are 1,2,3,1,2,3,1,2,3. You will get the most hugs if you arrive on the third day of the year: 3+1+2+3+1+2=12 hugs.
In the third test case, the numbers of the days are 1,2,3,4,1,2,1,2,3,1,1,2,3. You will get the most hugs if you come on the twelfth day of the year: your friend will hug you 2+3+1+2+3+4=15 times.
在第一个测试用例中,一年中各天的编号(即对应月份中的日期索引)为 {1,1,2,3,1}。若你在该年的第三天到访,Coronavirus-chan 将给予你最多的拥抱:2+3=5 次拥抱。
在第二个测试用例中,各天的编号为 {1,2,3,1,2,3,1,2,3}。若你在该年的第三天到访,你将获得最多的拥抱:3+1+2+3+1+2=12 次拥抱。
在第三个测试用例中,各天的编号为 {1,2,3,4,1,2,1,2,3,1,1,2,3}。若你在该年的第十二天到访,你将获得最多的拥抱:你的朋友将拥抱你 2+3+1+2+3+4=15 次。
输入解题思路,AI测评打分。不知道怎么写?