###### Codeforces Round #355 (Div. 2)

Codeforces Round #355 (Div. 2)

A. Vanya and Fence
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Vanya and his friends are walking along the fence of height h and they do not want the guard to notice them. In order to achieve this the height of each of the friends should not exceed h. If the height of some person is greater than h he can bend down and then he surely won't be noticed by the guard. The height of the i-th person is equal to ai.

Consider the width of the person walking as usual to be equal to 1, while the width of the bent person is equal to 2. Friends want to talk to each other while walking, so they would like to walk in a single row. What is the minimum width of the road, such that friends can walk in a row and remain unattended by the guard?

Input

The first line of the input contains two integers n and h (1 ≤ n ≤ 10001 ≤ h ≤ 1000) — the number of friends and the height of the fence, respectively.

The second line contains n integers ai (1 ≤ ai ≤ 2h), the i-th of them is equal to the height of the i-th person.

Output

Print a single integer — the minimum possible valid width of the road.

Examples
input
3 7
4 5 14
output
4
input
6 1
1 1 1 1 1 1
output
6
input
6 5
7 6 8 9 10 5
output
11
Note

In the first sample, only person number 3 must bend down, so the required width is equal to 1 + 1 + 2 = 4.

In the second sample, all friends are short enough and no one has to bend, so the width 1 + 1 + 1 + 1 + 1 + 1 = 6 is enough.

In the third sample, all the persons have to bend, except the last one. The required minimum width of the road is equal to2 + 2 + 2 + 2 + 2 + 1 = 11.

#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
int n,lim;
while(scanf("%d%d",&n,&lim)!=EOF){
int ans=0;
while(n--){
int tall;
scanf("%d",&tall);
if(tall>lim)
ans+=2;
else
ans++;
}
printf("%d\n",ans);
}
}

B. Vanya and Food Processor
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Vanya smashes potato in a vertical food processor. At each moment of time the height of the potato in the processor doesn't exceed hand the processor smashes k centimeters of potato each second. If there are less than k centimeters remaining, than during this second processor smashes all the remaining potato.

Vanya has n pieces of potato, the height of the i-th piece is equal to ai. He puts them in the food processor one by one starting from the piece number 1 and finishing with piece number n. Formally, each second the following happens:

1. If there is at least one piece of potato remaining, Vanya puts them in the processor one by one, until there is not enough space for the next piece.
2. Processor smashes k centimeters of potato (or just everything that is inside).

Provided the information about the parameter of the food processor and the size of each potato in a row, compute how long will it take for all the potato to become smashed.

Input

The first line of the input contains integers nh and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ h ≤ 109) — the number of pieces of potato, the height of the food processor and the amount of potato being smashed each second, respectively.

The second line contains n integers ai (1 ≤ ai ≤ h) — the heights of the pieces.

Output

Print a single integer — the number of seconds required to smash all the potatoes following the process described in the problem statement.

Examples
input
5 6 3
5 4 3 2 1
output
5
input
5 6 3
5 5 5 5 5
output
10
input
5 6 3
1 2 1 1 1
output
2
Note

Consider the first sample.

1. First Vanya puts the piece of potato of height 5 into processor. At the end of the second there is only amount of height 2 remaining inside.
2. Now Vanya puts the piece of potato of height 4. At the end of the second there is amount of height 3 remaining.
3. Vanya puts the piece of height 3 inside and again there are only 3 centimeters remaining at the end of this second.
4. Vanya finally puts the pieces of height 2 and 1 inside. At the end of the second the height of potato in the processor is equal to 3.
5. During this second processor finally smashes all the remaining potato and the process finishes.

In the second sample, Vanya puts the piece of height 5 inside and waits for 2 seconds while it is completely smashed. Then he repeats the same process for 4 other pieces. The total time is equal to 2·5 = 10 seconds.

In the third sample, Vanya simply puts all the potato inside the processor and waits 2 seconds.

test 9

45991 22981793 6964305

test 14

100000 1000000000 1

#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main()
{
long long n,lim,cut,sum,x,ans;
while(cin>>n>>lim>>cut){
ans=0;
//scanf("%d",&sum);
sum=0;
scanf("%I64d",&x);
long long i=1;
while(1){
if(sum+x>lim){
double tim=(sum+x-lim)/(double)cut;
long long t=(long long)ceil(tim);
ans+=t;
sum-=t*cut;
if(sum<0) sum=0;
}else{
sum+=x;
if(i>=n) break;
scanf("%I64d",&x);
i++;
}

}
ans+=sum/cut;
if(sum%cut!=0)
ans++;
cout<<ans<<endl;
}
}

C. Vanya and Label
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

While walking down the street Vanya saw a label "Hide&Seek". Because he is a programmer, he used & as a bitwise AND for these two words represented as a integers in base 64 and got new word. Now Vanya thinks of some string s and wants to know the number of pairs of words of length |s| (length of s), such that their bitwise AND is equal to s. As this number can be large, output it modulo 109 + 7.

To represent the string as a number in numeral system with base 64 Vanya uses the following rules:

• digits from '0' to '9' correspond to integers from 0 to 9;
• letters from 'A' to 'Z' correspond to integers from 10 to 35;
• letters from 'a' to 'z' correspond to integers from 36 to 61;
• letter '-' correspond to integer 62;
• letter '_' correspond to integer 63.
Input

The only line of the input contains a single word s (1 ≤ |s| ≤ 100 000), consisting of digits, lowercase and uppercase English letters, characters '-' and '_'.

Output

Print a single integer — the number of possible pairs of words, such that their bitwise AND is equal to string s modulo 109 + 7.

Examples
input
z
output
3
input
V_V
output
9
input
Codeforces
output
130653412
Note

For a detailed definition of bitwise AND we recommend to take a look in the corresponding article in Wikipedia.

In the first sample, there are 3 possible solutions:

1. z&_ = 61&63 = 61 = z
2. _&z = 63&61 = 61 = z
3. z&z = 61&61 = 61 = z

#### 【CodeForces】CodeForces Round #464 (Div. 2) 题解

2018-02-18 11:05:43

#### Codeforces Round #444 (Div. 2)-贪心&尺取-Ratings and Reality Shows

2017-11-11 20:11:11

#### Codeforces Round #471 div.2 ABC题解

2018-03-24 14:16:58

#### Codeforces Round #258 (Div. 2)-(A,B,C,D,E)

2014-07-25 14:39:48

#### Educational Codeforces Round 36 (Rated for Div. 2) 题解

2018-01-13 23:16:24

#### Codeforces Round #471 (Div. 2)

2018-03-27 23:23:41

#### ICM Technex 2018 and Codeforces Round #463 (Div. 1 + Div. 2, combined)

2018-02-16 09:21:04

#### Educational Codeforces Round 38 (Rated for Div. 2) B. Run For Your Prize

2018-02-17 13:35:37

#### Codeforces Round #446 (Div. 2) D. Gluttony

2017-11-18 21:07:25

#### 【解题报告】ICM Technex 2017 and Codeforces Round #400 (Div. 1 + Div. 2, combined)

2017-03-02 23:16:50

## 不良信息举报

Codeforces Round #355 (Div. 2)