## A. Maximum Increase

You are given array consisting of n integers. Your task is to find the maximum length of an increasing subarray of the given array.

A subarray is the sequence of consecutive elements of the array. Subarray is called increasing if each element of this subarray strictly greater than previous.

### Input

The first line contains single positive integer n ($1 \leq n \leq 10^5$) — the number of integers.

The second line contains n positive integers $a_1$, $a_2$, …, $a_n$ ($1 \leq a_i \leq 10^9$).

### OutPut

Print the maximum length of an increasing subarray of the given array.

### Examples

input
5
1 7 2 11 15
output
3

input
6
100 100 100 100 100 100
output
1

input
3
1 2 3
output
3


### 题解

//author: CHC
//First Edit Time:	2016-07-29 23:04
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <limits>
using namespace std;
typedef long long LL;
const int MAXN=1e+5 + 1000;
const int INF = numeric_limits<int>::max();
const LL LL_INF= numeric_limits<LL>::max();
int A[MAXN],n;
int main()
{
while(~scanf("%d",&n))
{
for(int i=1;i<=n;i++)
scanf("%d",&A[i]);
int cnt = 1;
int mcnt = 1;
for(int i=1;i<n;i++)
{
if(A[i]<A[i+1])
{
++cnt;
}
else
{
cnt = 1;
}
mcnt = max(mcnt,cnt);
}
printf("%d\n",mcnt);
}
return 0;
}


## B. Powers of Two

You are given n integers $a_1$, $a_2$, …, $a_n$. Find the number of pairs of indexes i, j (i < j) that a_i + a_j is a power of 2 (i. e. some integer x exists so that a_i + a_j = 2^x).

### Input

The first line contains the single positive integer n ($1 \leq n \leq 10^5$) — the number of integers.

The second line contains n positive integers $a_1$, $a_2$, …, $a_n$ ($1 \leq a_i \leq 10^9$).

### Output

Print the number of pairs of indexes i, j (i < j) that $a_i$ + $a_j$ is a power of 2.

### Examples

input
4
7 3 2 1
output
2

input
3
1 1 1
output
3


### 题解

//author: CHC
//First Edit Time:	2016-07-29 23:11
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <limits>
using namespace std;
typedef long long LL;
const int MAXN=1e+5 + 1000;
const int INF = numeric_limits<int>::max();
const LL LL_INF= numeric_limits<LL>::max();
LL A[MAXN];
int n;
int main()
{
while(~scanf("%d",&n))
{
for(int i=1;i<=n;i++)
scanf("%I64d",&A[i]);
sort(A+1,A+1+n);
LL cnt = 0;
for(int i=1;i<=n;i++)
{
for(int j=0;j<32;j++)
{
if((1LL<<j)>A[i])
{
LL x = (1LL<<j)-A[i];
int pos = lower_bound(A+i+1,A+1+n,x) - A;
if(pos>=1&&pos<=n&&A[pos]==x)
{
int pos1 = lower_bound(A+1,A+1+n,x+1) - A;
//printf("%d %d %d\n",i,pos,pos1);
cnt += (LL)(pos1 - pos);
}
}
}
}
printf("%I64d\n",cnt);
}
return 0;
}


## C. Cellular Network

You are given n points on the straight line — the positions (x-coordinates) of the cities and m points on the same line — the positions (x-coordinates) of the cellular towers. All towers work in the same way — they provide cellular network for all cities, which are located at the distance which is no more than r from this tower.

Your task is to find minimal r that each city has been provided by cellular network, i.e. for each city there is at least one cellular tower at the distance which is no more than r.

If r = 0 then a tower provides cellular network only for the point where it is located. One tower can provide cellular network for any number of cities, but all these cities must be at the distance which is no more than r from this tower.

### Input

The first line contains two positive integers n and m ($1 \leq n,m \leq 10^5$) — the number of cities and the number of cellular towers.

The second line contains a sequence of n integers a1, a2, …, an ($-10^9 \leq a_i \leq 10^9$) — the coordinates of cities. It is allowed that there are any number of cities in the same point. All coordinates ai are given in non-decreasing order.

The third line contains a sequence of m integers b1, b2, …, bm ($-10^9 \leq a_i \leq 10^9$) — the coordinates of cellular towers. It is allowed that there are any number of towers in the same point. All coordinates bj are given in non-decreasing order.

### Output

Print minimal r so that each city will be covered by cellular network.

### Examples

input
3 2
-2 2 4
-3 0
output
4

input
5 3
1 5 10 14 17
4 11 15
output
3


### 题解

//author: CHC
//First Edit Time:	2016-07-29 23:28
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <limits>
using namespace std;
typedef long long LL;
const int MAXN=1e+5 + 1000;
const int INF = numeric_limits<int>::max();
const LL LL_INF= numeric_limits<LL>::max();
int n,m;
LL A[MAXN],B[MAXN];
LL abss(LL x)
{
if(x<0) return -x;
else return x;
}
bool check(LL ans)
{
for(int i=1;i<=n;i++)
{
int pos = lower_bound(B+1,B+1+m,A[i]-ans) - B;
if(1<=pos&&pos<=m&&abss(B[pos]-A[i])<=ans);
else return false;
}
return true;
}
int main()
{
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++)
scanf("%I64d",&A[i]);
for(int i=1;i<=m;i++)
scanf("%I64d",&B[i]);
sort(A+1,A+1+n);
sort(B+1,B+1+m);
LL l=0,r=(1LL<<36),ans=0;
while(l<=r)
{
LL mid=(l+r)>>1;
if(check(mid))
{
ans=mid;
r=mid-1;
}
else l=mid+1;
}
printf("%I64d\n",ans);
return 0;
}


## D. Road to Post Office

Vasiliy has a car and he wants to get from home to the post office. The distance which he needs to pass equals to d kilometers.

Vasiliy’s car is not new — it breaks after driven every k kilometers and Vasiliy needs t seconds to repair it. After repairing his car Vasiliy can drive again (but after k kilometers it will break again, and so on). In the beginning of the trip the car is just from repair station.

To drive one kilometer on car Vasiliy spends a seconds, to walk one kilometer on foot he needs b seconds (a < b).

Your task is to find minimal time after which Vasiliy will be able to reach the post office. Consider that in every moment of time Vasiliy can left his car and start to go on foot.

### Input

The first line contains 5 positive integers d, k, a, b, t ($1 \leq d \leq 10^12$; $1 \leq k, a, b, t \leq 10^6$ ; a < b), where:

d — the distance from home to the post office;
k — the distance, which car is able to drive before breaking;
a — the time, which Vasiliy spends to drive 1 kilometer on his car;
b — the time, which Vasiliy spends to walk 1 kilometer on foot;
t — the time, which Vasiliy spends to repair his car.

### Output

Print the minimal time after which Vasiliy will be able to reach the post office.

### Examples

input
5 2 1 4 10
output
14

input
5 2 1 4 5
output
13


### 题解

$1 \leq d \leq 10^12$; $1 \leq k, a, b, t \leq 10^6$ ; a < b

//author: CHC
//First Edit Time:	2016-07-30 00:24
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <limits>
using namespace std;
typedef long long LL;
const int MAXN=1e+4;
const int MAXM=1e+5;
const int INF = numeric_limits<int>::max();
const LL LL_INF= numeric_limits<LL>::max();
LL d,k,a,b,t;
int main()
{
scanf("%I64d%I64d%I64d%I64d%I64d",&d,&k,&a,&b,&t);
LL ans = k*a;
if(k>d)
{
ans = d*a;
}
//printf("%I64d\n",ans);
if(k*a+t>b*k)
{
ans += (d-k)/k*k*b;
}
else
{
ans += (d-k)/k*(k*a+t);
}
//printf("%I64d\n",ans);
if((d-k)>0&&(d-k)%k!=0)
{
if(t+(d-k)%k*a > (d-k)%k*b)
{
ans += (d-k)%k*b;
}
else
{
ans += t+(d-k)%k*a;
}
}
printf("%I64d\n",ans);
return 0;
}