Codeforces Round #355 (Div. 2)

原创 2016年06月02日 07:24:26

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.


数学问题模拟就行(加取余以节约速度)

另Codeforces的格式限制:%I64d(win),不能%lld(linux)

或着用cout加取消stdio同步ios::sync_with_stdio(false)

大数据组说明(数据时间截至2016.6.2)

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 Round #355 (Div. 2) A. Vanya and Fence (水题)

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

Codeforces Round #355 (Div. 2) C. Vanya and Label

C. Vanya and Labeltime limit per test 1 second memory limit per test 256 megabytes input standa...

Codeforces Round #355 (Div. 2) B. Vanya and Food Processor(贪心)

B. Vanya and Food Processor time limit per test 1 second memory limit per test 256 megabytes i...

Codeforces Round #355 (Div. 2)- Vanya and Fence(模拟)

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

Codeforces Round #355 (Div. 2) C. Vanya and Label (打表+字符串)

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

Codeforces Round #355 (Div. 2) B. Vanya and Food Processor (模拟)

B. Vanya and Food Processortime limit per test 1 second memory limit per test 256 megabytes inpu...

codeforces round 355 div2 D Vanya and Treasure Dp 二维线段树

#pragma warning(disable:4786) #pragma comment(linker, "/STACK:102400000,102400000") #include #includ...

Codeforces Round #355 (Div. 2) D. Vanya and Treasure

Vanya is in the palace that can be represented as a grid n × m. Each room contains a single chest, ...

Codeforces Round #355 (Div. 2)-B. Vanya and Food Processor(模拟)

B. Vanya and Food Processor time limit per test 1 second memory limit per test 256 megab...

Codeforces Round #355 (Div. 2) 题解(待补)

Vanya and Fence Vanya and Food Processor Vanya and LabelVanya and Fenceint n=read(),h=read(),ans=0; ...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)