/*DEP TRAI CO J SAI*/
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@@@@@@%%##***************************+++++++++++++++++++++++++++++++++++++++++++++++***************************######%%%@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@@@@@%%####**************************++++++++++++++++++++++++++++++++++++++++++++++++***************************#######%%%@@@@@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@@@@@@@%%##**************************++++++++++++++++++++++++++++++++++++++++++++++++++****************************########%%@@@@@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@@@@@@%%%##***************************+++++++++++++++++++++++++++++++++++++++++++++++++++++++************************#########%%@@@@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@@@@@%%%##*************************++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++**********************##########%%%@@@@@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@@@@@%%##*************************+++++++++++++++++++++++++++++++++++++++++++++++++++++++++**+*********************#############%%@@@@@@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@@@@@%%%##*************************++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*********************########*######%@@@@@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@@@@@%%%####********************+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++**********************######**#######%%%@@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@@@@@%%%%##**************************++++++++++++++++++++++++++++++++++++++++++++++++++++++++++************************#####***#######%%@@@@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@@@@@%%%##***********************+*****+++++++++++++++++++++++++++++++++++++++++++++++++++++++++***********************######***######%%%@@@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@@@@@%%%##******************************+++++++++++++++++++++++++++++++++++++++++++++++++++++++++*************************####****#####%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@@@@%%%####*****************************++++++++++++++++++++++++++++++++++++++++++++++++++++++++++***********************###****########%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@@@@%%%####***************************++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++**********************#****#########%%@@@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@@@@%%###*****************************+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*************************########%%%@@@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@@@%%%###********************************+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*********************###**########%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@@@%%#####****************############*********++++++++++++++++++++++++++++++++++++++++++++++++++************###***#####################%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@@@%%#####************##%%%%%%%%%%%%%%%%%%%%%##***+++++++++++++++++++++++++++++++++++++++++++***####%%%%%%%@%%%%%%%%%%%%%################%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@@@%%######*******##%%%@@@@@@@@@@%%%%%%%%%@%%%%%%%##****++++++++++++++++++++++++++++++++++**###%%%%%%%%%%@@@@@@@@@@@@@@@@@%%##***#########%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@@@%%######*****#%%%@@@@@@@%%%%%%%%%%%%%%%%%%%%%%%%%%%####***++++++++++++++++++++++++++***###%%%%%%%%%%%%%%%%%%%%%%%%@@@@@@@%%%###########%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@@@%%#####****##%%%###%%%###**######%%%%%%%%%%%%%%%%%%%%%###***+++++++++++++++++++++******##%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@@@@%%#########%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@@@%%#####***#######**********+**********####################***+++++++++++++++++++******#######%%%%%%%%%#######*******####%%%%@%#########%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@@%%####*****************+++++++++++++++++************#*###****+++++++++++++++++++*****#######************+++++************##%%%%########%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@%%%###***#*******++**+++++++++++++++++++++++*****************+++++++++++++++++++*****##**************+++++++++++++++*******###%%#######%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@@%%###****************+++++++++++++++++++++++++*************++++++++++++++++++++*****#**********+++++++++++++++++++++********#########%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@@%%##*****************++*+++*******************************+++++++++++++++++++*******##******+++++++++++++++++++++************########%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@@%%##*******************************######**#####**********+++++++++++++++++*****#####*******+++++++++*+***++++****************###**##%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%%##***************##**####%%%%@@%%%%%%%%%%%##************++++++++++++++++******##************++++++++*****************************##%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*
@@@@@@@@@@@@@@@@@@@@@@@@%%##%%@@@%%#***************#####%%@@%##%%##*#%%####**##%##*************+++++++++*******#####*********######%%%%%%#############*#**********####%###%%%%%%%%%%%%%@@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*
@@@@@@@@@@@@@@@@@@@@@@@###***##%@%##************###%%@@@@@%%#**####%%%%##***++**#####*+***********+++++********###****#######****#***#%%%%%%%%%%%%######***********#########%%%%%%%%%@@@@@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*
@@@@@@@@@@@@@@@@@@@@@@@###******#%##**************##%%%%########********************+++**********++++++*******###*****####****++**###%%%######%%@@%%%%#####**********###***#%%%%%%%@@@@@@@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*
@@@@@@@@@@@@@@@@@@@@@@%#*##******##***********+++*******************++********++++++++**********++++++********####*******************##########%%%@@@@%%####*********##%####%%@@@@@@@@@@@@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*
@@@@@@@@@@@@@@@@@@@@@@%#*##******###******++++++++**********++**+*************++++++************++++++********####**********++**+++********#######%%%%%%###**********########%@@@@@@@@@@@@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*
@@@@@@@@@@@@@@@@@@@@@@#**##*****###*******+++++++++++++++++****************++++++++*************++++**********######*****************************#######**************##**####%@@@@@@@@@@@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*
@@@@@@@@@@@@@@@@@@@@@%*********####********++++++++++++++++++++++++++++++++++++++++**************++**+*********####********++++******************************************#####%@@@@@@@@@@@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*
@@@@@@@@@@@@@@@@@@@@@%********#####********+++++++++++++++++++++++++++++++++++++++++*************++++++*********####*******++++++++++++++++++++***********************#########%@@@@@@@@@@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*
@@@@@@@@@@@@@@@@@@@@@%*******######*******++++++++++++++++++++++++++++++++++++++++************+++++++++++********###*******++++++++++++++++++++++++++++*************#####*#####%@@@@@@@@@@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%##########%%%%%%%%%%*
@@@@@@@@@@@@@@@@@@@@@#**+++**#%###********+++++++++++++++++++++++++++++++++++++++***********++++++++++++++++*******#*******+++++++++++++++++++++++++++++++**********#####**####%%@@@@@@@@@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%###%######%%%%%%%%*
@@@@@@@@@@@@@@@@@@@@@#*++++**#####*******+++++++++++++++++++++++++++++++++++++++**********++++++++++++++++++++******##*****++++++++++++++++++++++++++++++++*********##*###**###%%@@@@@@@@@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%###%#################%%%%%%%%*
@@@@@@@@@@@@@@@@@@@@%#*++***######*******++++++++++++++++++++++++++++++++++++++********++++++++++++++++++++++++***********+++++++++++++++++++++++++++++++++++*******##*###****#%@@@@@@@@@@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#####################%%%%%%%%*
@@@@@@@@@@@@@@@@@@@@%*++****#####********+++++++++++++++++==+++++++++++++++++++****++++++++++++++++++++++++++++************++++++++++++++++++++++++++++++++++*******#**###****#%@@@@@@@@@@%%%%%%%%%%%%%%%%%%%#################################%%%%%%*
@@@@@@@@@@@@@@@@@@@@%**+****#%%###*******++++++++++++++++++++++++++++++++++++++**+++++++++++++++++++++++++++++**************+++++++++++++++++++++++++++++++++**********##*****#%@@@@@@@@@@%%%%%%%%%%%%########################################%%%%%%*
@@@@@@@@@@@@@@@@@@@@%#*****##%%###*******+++++++++++++++++++++++++++++++++++++***++++++*********++++++++++++****************+++++++++++++++++++++++++++++++++***********#*****#%@@@@@@@@@@%%%%%%%%############################################%%%%%%*
@@@@@@@@@@@@@@@@@@@@%#*****##%%###*******+++++++++++++++++++++++++++++++++++++**++***#%%@@@@@@@%#*++++++++**##%@@%%##********++++++++++++++++++++++++++++++++***********##****#%@@@@@@@@@@%%%%%%%#############################################%%%%%%*
@@@@@@@@@@@@@@@@@@@@@#******#%%####*******++++++++++++++++++++++++++++++++++++******###%%@@@@@%##***++++***#@@@@@@%%###*******+++++++++++++++++++++++++++++++******#****###**#%%@@@@@@@@@@%%%%%%%#############################################%%%%%%*
@@@@@@@@@@@@@@@@@@@@@%******#%%####*******++++++++++++++++++++++++++++++++++++*************#**************##%%%%%%##**********+++++++++++++++++++++++++++++************####**#%@@@@@@@@@@@%%%%%%%#############################################%%%%%%*
@@@@@@@@@@@@@@@@@@@@@@#*****#%%%###*********++++++++++++++++++++++++++++++++++******+++++++++++*********###********+++***#*****+++++++++++++++++++++++++++*************#%#####%@@@@@@@@@@@%%%%%%%##############################################%%%%%*
@@@@@@@@@@@@@@@@@@@@@@%#****#%%%%##**********++++++++++++++++++++++++++++++++++********+++++++*************************####****++++++++++++++++++++++++****************#%#**#%%@@@@@@@@@@@%%%%%%###############################################%%%%%*
@@@@@@@@@@@@@@@@@@@@@@@%%%%##%%%%###*********+++++++++++++++++++++++++++++++++++++******+++++++++++***************#######*******++++++++++++++++++++++*****************%%###%%@@@@@@@@@@@@%%%%%%%##############################################%%%%%*
@@@@@@@@@@@@@@@@@@@@@@@%%%%%%%%%%%####************++++++++++++++++++++++++++++++++++++++++*++++++++++++++++*********************++++++++++++++++**********************#%%%%%%@@@@@@@@@@@@%%%%%%%%##############################################%%%%%*
@@@@@@@@@@@@@@@@@@@@@@@%##*#%%%%%%######***********++++++++++++++++++++++++++++++++++*+****#*****+++++++***#####********************++++++++++++******************##*#%%%%%%%%@@@@@@@@@@@%%%%%%%%###############################################%%%%*
@@@@@@@@@@@@@@@@@@@@@@@@%%###%@%%%%######*************+++++++++++++++++++++++++++*****####%%%%%%##**+**###%%%%%%%##*********************+++++*******************######%%%####%@@@@@@@@@@@%%%%%%%################################################%%%%*
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%%%%%#######**********+++++++++++++++++++++++++****###%#%%%%%%%%%%#****##%%%%%%%%%%%%##****************************************########%%%###%%%@@@@@@@@@@%%%%%%%#################################################%%%*
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%%%%%%######*********++++++++++++++++**********####%#%%%%%%%%%%%%%####%%###%%%%%@@@@%%###**********************************##########%%%####%%%%%@@@@@@@%%%%%%%%#################################################%%%*
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%%%%%%%#######************++****+******########%%%%###***********#######*****####%%%%%%%%%######**************************######%%%%##%#####%%%%%@@@@@@%%%%%%%%%################################################%%%%*
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%%%%%%%%%#####**********************####%%%%%#####**********++++++******************###%%%%%%%#####*******************########%%%%%%#%%######%%%%%%%%%%%%%%%%%%#################################################%%%%*
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%%%%%%%%#%#####******************######%%###*******************************************##%#%%%%%%####***************#########%%%%%%%%#######%%%%%%%%%%%%%%%%%%##################################################%%%*
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%%%#%%%%%%%#####***************##########****************************************######*#####%%%%%%%#######*******########%%%%%%##%#%########%%%%%%%%%%%%%%%%%##################################################%%%*
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%%%###%%%%%#####**************#########********################################################%%%%%%%#####*****######%%%%%%%%%##%%%%########%%%%%%%%%%%%%%%%%#################################################%%%%*
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%%%##%%%%%%######************#####****#########################################################%%%%%%%##############%%%%%%%%%#%%%%%#########%%%%%%%%%%%%%%%%###################################################%%%*
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%%%%%%%%%%%%%#####***********####***###############*####****####**###############################%%%%%############%%%%%%%%%%%%%%%%##########%%%%%%%%%%%%%%%%####################################################%%*
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%%%%%%%%%%%%%%%###**********##***#####%%#####**********************************#####%%%%%#########%%%###########%%%%%%%%##%%%%%%%##########%%%%%%%%%%%%%%%%###################################################%%%*
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%%%%%%%%%%%%%%###**************########*************+++++++++++++++*************#############*###############%%%%%%%%##%%%%%%%%##########%%%%%%%%%%%%%%%####################################################%%%*
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%%%%%%%%%%%%%###****************######********++++++++++++++++++++++++++*******###########******#########%%%%%%%%%%%#%%%%%%%%############%%%%%%%%%%%%%%####################################################%%%*
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%%%%%%%%%%%%%####***************************+++++++++++++++++++++++++++++*********#######******##########%%%%%%%%%%%%%%%%%%%##############%%%%%%%%%%%%%####################################################%%%*
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%%%%%%%%%%%%###******************************++++++++++++++++++++++++++*********########****###########%%%%%%%%%%%%%%%%%%%##############%%%%%%###########################################################%%%*
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%%%@@@@@%%%###*****************##*****************+*****************************#######***###########%%%%%%%@%%%%%%%%%%################%%%%%############################################################%%%*
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%%%@@%%@@@@@@%%%#####**************######***************************************#########*****###########%%%%%@@@@%%%%%%%%######****#######%%%%%%%###########################################################%%*
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%%%%%@@@@@@@@%%%######******************###########%#%%%%%%%%%%%%%%%%%%%%%%%##########*******###########%%%@@@@@@@@@%%%%%#####***#**#######%%%%%%############################################################%%*
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%%%%%@@@@@@@@@%%%#####*********************######%#####%%%%%%%%%%%%%%%%#%%%%####***********#############%%%@@@@@@@@@@@%%####*******#########%%%%%############################################################%%*
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%####%%@@@@@@@@%%%######*************************############%%%%%%%%%%#####***************############%%%%@@@@@@@@@@%%###*#*******#########%%%%%############################################################%%*
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%#####%%%%@@@@@@@%%#####**********************++++************####*#######***************#############%%%%@@@@@@@@@%%%%#***********#########%%%%%############################################################%%*
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%%#######%@@@@@@@%%%%####****************+++++++++++++++++++++*+++*+*******************##############%%%%@@@@@@@@%%%%%##************#######%%%%%%############################################################%%*
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%#######%%%%@@@@%%%%%###***************+++++++++++++++++++++++++++++++++++************##############%%%%@@@@@@@%%%%###*************#######%%%%%%############################################################%%*
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%##****###%%%@@@@@%%%%%##*************+++++++++++++++++++++++++++++++++++++****************#######%%%%@@@@@@@@%%######*************#######%%%%%%%%##########################################################%%*
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%##******###%%%@@@@@@%%%##************+++++++++++++++++++++++++++++++++++++***************######%%%%%@@@@@@@%%%#######*************#######%%%%%%%%%%########################################################%%*
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%##*********##%%%%@@@%%%%##******++++++++++++***+++++*++++++++++++**++********************####%%%%@@@@@@@@@%%%#######**************#######%%%%%%%%%%#########################################################%*
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%##***********###%%%@@@@%%%##****++++********************++++++++************************##%%%%%%@@@@@@%%%%#####*#####**************######%%%%%%%%%%%########################################################%*
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%###************###%%@@@@%%%##******+*******#****###******************##########*****#####%%%%%%@@@@@%%%%####*#***###**************#######%%%%%%%%%%%%######################################################%%*
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%##**************##%%%@@@@%%####******##############****#****#########%%%%%%%#######%%%%%%%%@@@@%%%%######********##**************#######%%%%%%%%%%%%%#####################################################%%*
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%##****************##%%%@@@@%%######*#########################%%#%%%%%%%%%%%%%%%%%%%%%%%%@@@@@%%%%%####***********##**************######%%%%%%%%%%%%%#######################################################%*
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%##*****************###%%%%@@@%%%%%%%%%%%%%%%%%%%%%%%%%#%####%%%%%%%%%%%%%@@%%%%%%%%@@@@@@@@%%%%%####*************##**************#######%%%%%%%%%%%%#######################################################%*
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%##*************++*****##%%%@@@@@@@%%@%%%%%%@%%%%%%%%%%%%%%%%%%%%%%%@@@@@@@@@@%%%%@@@@@@@@%%%%%####***************##****************#####%%%%%%%%%%%%#######################################################%*
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%##**********+++++*******###%%@@@@@@@@@@@@@@@@@@@@@@@@@%%%%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%%%%%####***************#*#*****************#####%%%%%%%%%%%%%######################################################%*
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%##********+++++++++++******#%%%%%%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%%%####********************##****************#####%%%%%%%%%%%%%######################################################%*
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%%%%%#******++++++++++++++++++******####%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%###*********************************************#####%%%%%###############****#########################################%*
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%*++============================================================================================================================================================================++*#################################%*
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#+==================================================================================================================================================================================+################################%*
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#+===================================================================================================================================================================================+*################################*
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#+====================================================================================================================================================================================*################################*
@@@@@@@@@@@@@@@@@@@@@@@@@%%%#*==============================================*%@@@%*=============================================================+#%%#+========+*##*+==+##*=========================================*################################*
@@@@@@@@@@@@@@@@@@@@@%%%#####+==========+%@@@@@@@@@@@@@@@%#*+==============*@@@@#+===+****+====================================================*%@@@@%*======*%@@@@@%#%@@#+==+****+================================*################################*
@@@@@@@@@@@@@@@@%%%#####*****+==========+%@@@@@@@@@@@@@@@@@@@#+===========*@@@%*=====#@@@@*===+*%@@@@#+========================================+#@@@@#+=====+#@@#*#%@@@@%+==+#@@@%*================================+################################*
@@@@@@@@@@@%%%#####**********+==========+%@@@@@#*++++**#@@@@@@%+=========+****+====+#@@@@#+====#@@@@@#+==========================================++++=======+***+==++***==+*#@@@@#+================================+################################*
@@@@@%%%%#####***************+==========+%@@@@@*========*@@@@@@+========++**##%%%%@@@@@@#+==+**%@@@@@%****===============++*####*++==+*****+===+******+========+**###%%%%@@@@@@%*+=+******==+**####*++=============+################################*
%%%######********************+==========+%@@@@@*========*@@@@@%+======*#@@@@@@@@@@@@@%*=====#@@@@@@@@@@@@%+============+#@@@@@@@@@@#*%@@@@@*===+@@@@@%+=====+#%@@@@@@@@@@@@@#++====*@@@@@%*%@@@@@@@@@%*+===========*###############################%*
#####*****************+++++**+==========+%@@@@@#++++++*#@@@@@#+=====+#@@@@@@@%%%@@@@@@%*+===*%%@@@@@@@%%%#+===========*@@@@@@@@@%@@@@@@@@@@*===+@@@@@%+===+#@@@@@@@%%%@@@@@@@#+====*@@@@@@@@@@@@@@@@@@@#+==========*###############################%*
**************++++++++++++***+==========+%@@@@@@@@@@@@@@@@%*+======+%@@@@@#+====+*%@@@@@*+====+#@@@@@%+==============*%@@@@@#*====+*%@@@@@@*===+@@@@@%+===#@@@@@%*+====+%@@@@@%+===*@@@@@@%+====+#@@@@@%*==========*################################*
************+++++++++++++++**+==========+%@@@@@@@@@@@@@@@@@@@#*====*@@@@@%+=======*@@@@@%+=====#@@@@@%+=============+#@@@@@#+=======*@@@@@@*===+%@@@@%+==*@@@@@%*=======+%@@@@@*===*@@@@@%+======+%@@@@@*==========*###############################%*
******++++++++++++++++++++++++==========+%@@@@@*+======+*%@@@@@%+=+#@@@@@#========+%@@@@@*=====#@@@@@%+=============+%@@@@@*========+%@@@@@*===+%@@@@%+==*@@@@@%+========#@@@@@#===*@@@@@%+======+%@@@@@*==========+##############################%%*
***+++++++++++++++++++++++++++==========+%@@@@@*=========+%@@@@@#=+#@@@@@#+=======+%@@@@@*=====#@@@@@%+=============+#@@@@@#========+%@@@@@*===+%@@@@%+==*@@@@@%+=======+%@@@@@*===*@@@@@%+======+%@@@@@*==========+*******#######################%%*
+***++++++++++++++++++++++++++==========+%@@@@@*=========*%@@@@@#==*@@@@@%*======+#@@@@@%+=====#@@@@@#+==============*@@@@@@*======+#@@@@@@*===+%@@@@%+==+%@@@@@*=======*@@@@@@*===*@@@@@%+======+%@@@@@*==========+***********#####################*
+++++++++++++++++++++++++++*++==========+%@@@@@#+++++++*#@@@@@@%*===#@@@@@@#++++*%@@@@@%*======*@@@@@%*+=============+#@@@@@@%#***#@@@@@@@@*===+%@@@@%+===*%@@@@@#*+++*#@@@@@@*====*@@@@@%+======+%@@@@@*==========+***************#################*
**+*+++++++++++++++++++++++**+==========+%@@@@@@@@@@@@@@@@@@@@#+=====*%@@@@@@@@@@@@@@@#+=======+%@@@@@@@@%+===========+*%@@@@@@@@@@%#%@@@@@*===+%@@@@%+====*%@@@@@@@@@@@@@@@%*=====*@@@@@%+======+%@@@@@*==========+**********######################*
*****++++++++++++++++++++++**+==========+%@@@@@@@@@@@@@@@@%#*+=========+#%@@@@@@@@%%*+==========+#%@@@@@@%+==============+*#%%%%#*+++%@@@@@*===+%@@@@%+======+#%@@@@@@@@@%#++======*@@@@@#+======+%@@@@%*==========+*###############################*
##*************++++++++******+=============================================+++++++==================++++++===========+******+=======*@@@@@%+=====================+++++++===========================================*#######*******##################*
#########********************+=======================================================================================+#@@@@@@%#**##%@@@@@%*========================================================================+##**************################*
#################************+=========================================================================================+#@@@@@@@@@@@@@@%*+=========================================================================+*****************###############*
*****########################*============================================================================================+**#######*++============================================================================+*****************##*############+
*********####################*=====================================================================================================================================================================================+********************************+
***************###############+===================================================================================================================================================================================+*********************************+
*********************##########++================================================================================================================================================================================+**********************************+
***#*************************###***++++++++++++++++++++++++++++++++==+++++++=++++++====+++====+==========++++++=+++++++++++++++++++++=+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*************************************+ */
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pu emplace_back
#define ll long long
#define mp make_pair
typedef pair <ll,ll> ii;
const int N=1e6;
long long mod=1e17;
ll n,k;
ll a[N+1],f[N+10];
string s;
ii dp[N+10];
int calc(ll c)
{
ii mx = {0, 0};
for (int i = 1; i <= n; i++)
{
mx = max(mx, {dp[i-1].fi - f[i-1], dp[i-1].se});
dp[i] = max(dp[i-1], {f[i] + mx.fi - c, mx.se+1});
}
return dp[n].se;
}
void tinh(){
cin>>n>>k;
for(int i=1;i<=n;i++) cin>>a[i];
for(int i=1;i<=n;i++) f[i]=f[i-1]+a[i];
ll ans=0,l=0,r=mod;
while(l<=r){
ll mid=(l+r)/2LL;
if(calc(mid)>k) l=mid+1;
else {
ans=mid;
r=mid-1;
}
}
calc(ans);
cout<<dp[n].fi+ans*dp[n].se;
}
int main(){
ios_base::sync_with_stdio(false);
//freopen("ahihi.inp","r",stdin);
//freopen("ahihi.out","w",stdout);
cin.tie(0);
cout.tie(0);
tinh();
return 0;
}
// code cua anh Trần Tuấn nam đẹp trai nhất CHL
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
52 ms |
9544 KB |
Output is correct |
2 |
Correct |
53 ms |
9556 KB |
Output is correct |
3 |
Correct |
55 ms |
9800 KB |
Output is correct |
4 |
Correct |
53 ms |
9660 KB |
Output is correct |
5 |
Correct |
63 ms |
9652 KB |
Output is correct |
6 |
Correct |
52 ms |
9576 KB |
Output is correct |
7 |
Correct |
54 ms |
9464 KB |
Output is correct |
8 |
Correct |
54 ms |
9544 KB |
Output is correct |
9 |
Correct |
70 ms |
9552 KB |
Output is correct |
10 |
Correct |
78 ms |
9664 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
49 ms |
9720 KB |
Output is correct |
2 |
Correct |
50 ms |
9808 KB |
Output is correct |
3 |
Correct |
52 ms |
9552 KB |
Output is correct |
4 |
Correct |
49 ms |
9552 KB |
Output is correct |
5 |
Correct |
50 ms |
9776 KB |
Output is correct |
6 |
Correct |
46 ms |
9552 KB |
Output is correct |
7 |
Correct |
47 ms |
10064 KB |
Output is correct |
8 |
Correct |
52 ms |
9568 KB |
Output is correct |
9 |
Correct |
54 ms |
9544 KB |
Output is correct |
10 |
Correct |
58 ms |
9820 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
80 ms |
9552 KB |
Output is correct |
2 |
Correct |
81 ms |
9504 KB |
Output is correct |
3 |
Correct |
78 ms |
9544 KB |
Output is correct |
4 |
Correct |
79 ms |
9544 KB |
Output is correct |
5 |
Correct |
89 ms |
9716 KB |
Output is correct |
6 |
Correct |
83 ms |
9548 KB |
Output is correct |
7 |
Correct |
109 ms |
9720 KB |
Output is correct |
8 |
Correct |
82 ms |
9552 KB |
Output is correct |
9 |
Correct |
96 ms |
9852 KB |
Output is correct |
10 |
Correct |
85 ms |
9808 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
504 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
504 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
1 ms |
336 KB |
Output is correct |
17 |
Correct |
1 ms |
336 KB |
Output is correct |
18 |
Correct |
1 ms |
336 KB |
Output is correct |
19 |
Correct |
1 ms |
336 KB |
Output is correct |
20 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
504 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
1 ms |
336 KB |
Output is correct |
17 |
Correct |
1 ms |
336 KB |
Output is correct |
18 |
Correct |
1 ms |
336 KB |
Output is correct |
19 |
Correct |
1 ms |
336 KB |
Output is correct |
20 |
Correct |
1 ms |
336 KB |
Output is correct |
21 |
Correct |
2 ms |
336 KB |
Output is correct |
22 |
Correct |
1 ms |
336 KB |
Output is correct |
23 |
Correct |
2 ms |
336 KB |
Output is correct |
24 |
Correct |
1 ms |
336 KB |
Output is correct |
25 |
Correct |
1 ms |
336 KB |
Output is correct |
26 |
Correct |
1 ms |
400 KB |
Output is correct |
27 |
Correct |
1 ms |
336 KB |
Output is correct |
28 |
Correct |
1 ms |
336 KB |
Output is correct |
29 |
Correct |
2 ms |
336 KB |
Output is correct |
30 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
52 ms |
9544 KB |
Output is correct |
2 |
Correct |
53 ms |
9556 KB |
Output is correct |
3 |
Correct |
55 ms |
9800 KB |
Output is correct |
4 |
Correct |
53 ms |
9660 KB |
Output is correct |
5 |
Correct |
63 ms |
9652 KB |
Output is correct |
6 |
Correct |
52 ms |
9576 KB |
Output is correct |
7 |
Correct |
54 ms |
9464 KB |
Output is correct |
8 |
Correct |
54 ms |
9544 KB |
Output is correct |
9 |
Correct |
70 ms |
9552 KB |
Output is correct |
10 |
Correct |
78 ms |
9664 KB |
Output is correct |
11 |
Correct |
49 ms |
9720 KB |
Output is correct |
12 |
Correct |
50 ms |
9808 KB |
Output is correct |
13 |
Correct |
52 ms |
9552 KB |
Output is correct |
14 |
Correct |
49 ms |
9552 KB |
Output is correct |
15 |
Correct |
50 ms |
9776 KB |
Output is correct |
16 |
Correct |
46 ms |
9552 KB |
Output is correct |
17 |
Correct |
47 ms |
10064 KB |
Output is correct |
18 |
Correct |
52 ms |
9568 KB |
Output is correct |
19 |
Correct |
54 ms |
9544 KB |
Output is correct |
20 |
Correct |
58 ms |
9820 KB |
Output is correct |
21 |
Correct |
80 ms |
9552 KB |
Output is correct |
22 |
Correct |
81 ms |
9504 KB |
Output is correct |
23 |
Correct |
78 ms |
9544 KB |
Output is correct |
24 |
Correct |
79 ms |
9544 KB |
Output is correct |
25 |
Correct |
89 ms |
9716 KB |
Output is correct |
26 |
Correct |
83 ms |
9548 KB |
Output is correct |
27 |
Correct |
109 ms |
9720 KB |
Output is correct |
28 |
Correct |
82 ms |
9552 KB |
Output is correct |
29 |
Correct |
96 ms |
9852 KB |
Output is correct |
30 |
Correct |
85 ms |
9808 KB |
Output is correct |
31 |
Correct |
1 ms |
336 KB |
Output is correct |
32 |
Correct |
1 ms |
336 KB |
Output is correct |
33 |
Correct |
1 ms |
336 KB |
Output is correct |
34 |
Correct |
1 ms |
336 KB |
Output is correct |
35 |
Correct |
1 ms |
336 KB |
Output is correct |
36 |
Correct |
1 ms |
336 KB |
Output is correct |
37 |
Correct |
1 ms |
504 KB |
Output is correct |
38 |
Correct |
1 ms |
336 KB |
Output is correct |
39 |
Correct |
1 ms |
336 KB |
Output is correct |
40 |
Correct |
1 ms |
336 KB |
Output is correct |
41 |
Correct |
1 ms |
336 KB |
Output is correct |
42 |
Correct |
1 ms |
336 KB |
Output is correct |
43 |
Correct |
1 ms |
336 KB |
Output is correct |
44 |
Correct |
1 ms |
336 KB |
Output is correct |
45 |
Correct |
1 ms |
336 KB |
Output is correct |
46 |
Correct |
1 ms |
336 KB |
Output is correct |
47 |
Correct |
1 ms |
336 KB |
Output is correct |
48 |
Correct |
1 ms |
336 KB |
Output is correct |
49 |
Correct |
1 ms |
336 KB |
Output is correct |
50 |
Correct |
1 ms |
336 KB |
Output is correct |
51 |
Correct |
2 ms |
336 KB |
Output is correct |
52 |
Correct |
1 ms |
336 KB |
Output is correct |
53 |
Correct |
2 ms |
336 KB |
Output is correct |
54 |
Correct |
1 ms |
336 KB |
Output is correct |
55 |
Correct |
1 ms |
336 KB |
Output is correct |
56 |
Correct |
1 ms |
400 KB |
Output is correct |
57 |
Correct |
1 ms |
336 KB |
Output is correct |
58 |
Correct |
1 ms |
336 KB |
Output is correct |
59 |
Correct |
2 ms |
336 KB |
Output is correct |
60 |
Correct |
1 ms |
336 KB |
Output is correct |
61 |
Correct |
107 ms |
9556 KB |
Output is correct |
62 |
Correct |
105 ms |
9860 KB |
Output is correct |
63 |
Correct |
89 ms |
12412 KB |
Output is correct |
64 |
Correct |
113 ms |
12616 KB |
Output is correct |
65 |
Correct |
117 ms |
12636 KB |
Output is correct |
66 |
Correct |
113 ms |
12624 KB |
Output is correct |
67 |
Correct |
118 ms |
12592 KB |
Output is correct |
68 |
Correct |
86 ms |
12616 KB |
Output is correct |
69 |
Correct |
79 ms |
12360 KB |
Output is correct |
70 |
Correct |
76 ms |
12484 KB |
Output is correct |