注册 登录  
 加关注
查看详情
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

Minary_Acdream

http://f10.moe/

 
 
 

日志

 
 

Codeforces Round #167 (Div. 2)  

2013-02-14 10:58:23|  分类: CodeForces |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
这次CF第一题照样是签到题,但是由于老了,找不到纸笔的情况下,心算了半天还算错,比赛开始20几分钟后才AC。
第二题应该是公式转换吧,没有仔细看,先看了第三题,第三题类似俄罗斯方块,区别在于它是从第一块的位置开始下落的,求的是每块方块下落后距离第一块的距离。于是继续脑补,可惜在比赛结束前由于没有考虑到其中一种情况就WA了,不过今天还是顺利的解决了。
     下面附上题目和代码。题目的具体意思就不展开了,该起床吃饭了0 0、
题目:
A. Dima and Friends
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Dima and his friends have been playing hide and seek at Dima's place all night. As a result, Dima's place got messy. In the morning they decided that they need to clean the place.

To decide who exactly would clean the apartment, the friends want to play a counting-out game. First, all the guys stand in a circle, and then each of them shows some number of fingers on one hand (one to five), and then the boys count in a circle, starting from Dima, the number of people, respective to the total number of fingers shown. The person on who the countdown stops will clean the apartment.

For example, if Dima and one of his friends played hide and seek, and 7 fingers were shown during the counting-out, then Dima would clean the place. If there were 2 or say, 8 fingers shown, then his friend would clean the place.

Dima knows how many fingers each of his friends will show during the counting-out. Now he is interested in the number of ways to show some number of fingers on one hand (one to five), so that he did not have to clean the place. Help Dima.

Input

The first line contains integer n (1?≤?n?≤?100) — the number of Dima's friends. Dima himself isn't considered to be his own friend. The second line contains n positive integers, not exceeding 5, representing, how many fingers the Dima's friends will show.

The numbers in the lines are separated by a single space.

Output

In a single line print the answer to the problem.

Sample test(s)
input
1
1
output
3
input
1
2
output
2
input
2
3 5
output
3
Note

In the first sample Dima can show 13 or 5 fingers. If Dima shows 3 fingers, then the counting-out will go like that: Dima, his friend, Dima, his friend.

In the second sample Dima can show 2 or 4 fingers.

代码:


#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;

int main()
{
int n;
while(~scanf("%d",&n))
{
int Count = 0,Sum = 0;
for(int i = 0;i < n;i ++)
{
int a;
scanf
("%d",&a);
Sum += a;
}
if(n == 1) { for(int i = 1;i <= 5;i ++){if((Sum + i) % (n + 1) != 1) Count++;} }
else{
for(int i = 1;i <= 5;i ++)
{
if((Sum + i) % (n + 1) != 1) {Count++;}
}
}

printf
("%d\n",Count);
}

}



C. Dima and Staircase
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Dima's got a staircase that consists of n stairs. The first stair is at height a1, the second one is at a2, the last one is at an (1?≤?a1?≤?a2?≤?...?≤?an).

Dima decided to play with the staircase, so he is throwing rectangular boxes at the staircase from above. The i-th box has width wi and height hi. Dima throws each box vertically down on the first wi stairs of the staircase, that is, the box covers stairs with numbers 1,?2,?...,?wi. Each thrown box flies vertically down until at least one of the two following events happen:

  • the bottom of the box touches the top of a stair;
  • the bottom of the box touches the top of a box, thrown earlier.

We only consider touching of the horizontal sides of stairs and boxes, at that touching with the corners isn't taken into consideration. Specifically, that implies that a box with width wi cannot touch the stair number wi?+?1.

You are given the description of the staircase and the sequence in which Dima threw the boxes at it. For each box, determine how high the bottom of the box after landing will be. Consider a box to fall after the previous one lands.

Input

The first line contains integer n (1?≤?n?≤?105) — the number of stairs in the staircase. The second line contains a non-decreasing sequence, consisting of n integers, a1,?a2,?...,?an (1?≤?ai?≤?109ai?≤?ai?+?1).

The next line contains integer m (1?≤?m?≤?105) — the number of boxes. Each of the following m lines contains a pair of integers wi,?hi(1?≤?wi?≤?n; 1?≤?hi?≤?109) — the size of the i-th thrown box.

The numbers in the lines are separated by spaces.

Output

Print m integers — for each box the height, where the bottom of the box will be after landing. Print the answers for the boxes in the order, in which the boxes are given in the input.

Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cincout streams or the %I64dspecifier.

Sample test(s)
input
5
1 2 3 6 6
4
1 1
3 1
1 1
4 3
output
1
3
4
6
input
3
1 2 3
2
1 1
3 1
output
1
3
input
1
1
5
1 2
1 10
1 10
1 10
1 10
output
1
3
13
23
33
Note

The first sample are shown on the picture.

2013年02月14日 - Minary - Minary_Acdream

代码:其实就是更新每一块下落后此时的状态。


#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
__int64 line
[100001];
int main()
{
int n;
while(~scanf("%d",&n))
{
memset
(line,0,sizeof(line));
for(int i = 1;i <= n;i ++)
{
__int64 j
; scanf("%I64d",&j);
line
[i] = j;
}
int m; scanf("%d",&m);
while(m --)
{
__int64 w
,h;
scanf
("%I64d %I64d",&w,&h);
for(int i = 1;i <= n;i ++)
{
if(line[i] >= w)
{
if(line[w] - line[i] > 0) printf("%I64d\n",line[i] + (line[w] - line[i]));
else printf("%I64d\n",line[i]);

if(line[i] == w)
{
__int64 h1
;
if(line[w] - line[i] > 0) h1 = line[i] + h + (line[w] - line[i]);
else h1 = line[i] + h;

for(int j = i;j > 0;j --)
{
line
[j] = h1;
}
/*

printf("--------------\n");
for(int k = 1;k <= n;k ++)
{
printf("%I64d ",line[k]);
}

printf("\n--------------\n");*/

break;
}
else
{
__int64 h1
;
if(line[w] - line[i] > 0) h1 = line[i] + h + (line[w] - line[i]);
else h1 = line[i] + h;
for(int j = i + w - 1;j > 0;j --)
{
line
[j] = h1;
}

/*

printf("--------------\n");
for(int k = 1;k <= n;k ++)
{
printf("%I64d ",line[k]);
}

printf("\n--------------\n");*/

break;
}
}
}
}
}
}
/*
Input
5
4 7 10 12 12
9
3 9
2 1
3 5
4 7
1 1
5 1
1 7
2 4
4 10
Answer
10
19
20
25
32
33
34
41
45*/



  评论这张
 
阅读(179)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2018