6984: BZOJ2984:[Balkan2009]strip

Memory Limit:128 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

给一条长为N~10^18的纸带,从左到右每个整数的位置标号为0..N,接下来有K~1W个操作,每次选取位置X,将整条纸带在X处对折。如果X是边缘则什么也不做。问最后纸带长度。


输入格式


输出格式


样例输入

9 5 
5 9 2 8 3 

样例输出

2

提示

The segment names look as follows: 
Starting situation: {0 1 2 3 4 5 6 7 8 9}.
Consecutively applying the folds:

The segment names look as follows: 
Starting situation: {0 1 2 3 4 5 6 7 8 9}.
Consecutively applying the folds:
--> {0 (1;9) (2;8) (3;7) (4;6) 5} --> {(1;9) (0;2;8) (3;7) (4;6) 5} --> {(0;2;8) (1;3;7;9) (4;6) 5} -->
{(0;2;8) (1;3;7;9) (4;6) 5} --> {(1;3;7;9) (0;2;4;6;8) 5}. 
 
 


题目来源

没有写明来源

加入题单

算法标签: