URAL 1910. Titan Ruins: Hidden Entrance
来源:互联网 发布:vue.js 获取url参数 编辑:程序博客网 时间:2024/06/10 05:23
1910. Titan Ruins: Hidden Entrance
Time limit: 1.0 second
Memory limit: 64 MB
Memory limit: 64 MB
Soren and Alba were famous and powerful wizards. They had been the founders of a magic guild that had united wizards of the Northern Territories and given them freedom and independence from the Southern Empire. Despite their venerable age, the friends still took an active part in all important events. When explorers of the Aspen Gorges found the remains of structures built by ancient Titans, who had created the world, Soren and Alba were among the first wizards to arrive to the place. They knew that Titans had been the most powerful wizards ever, and almost any study of their traces would give a strong impulse to the development of modern magic and would allow to understand the nature of magic on the whole.
When Soren and Alba approached the Titan Ruins, they saw a blank wall standing out only a little bit against a rock. The wall was divided into small identical sections.
`Where's the entrance?' Soren asked.
`It's hidden, I suppose,' Alba said. `Did you think that Titans would open the gate for you? They were always very serious about their safety. But I'm sure there's a real door somewhere among these sections. As far as I remember, all Titans' structures that we know have a door, and its width is exactly three such sections.'
`That's good, but how can we find it? The wall is long, and the spell for dispersing such illusions requires much magic power. We can't apply the spell to the whole wall.'
`Yes, the Masking Spell affects the whole wall, but its force is nonuniform. I'm almost sure the spell is strongest exactly where the door is hidden. I have just activated the Magic Field Scanning Spell, and very soon we'll know the force of the field acting on each section. We'll only have to choose three consecutive sections with maximum total force of the field and apply the Dispersal Spell to these sections.'
Input
The first line contains the number n of sections in the wall (3 ≤ n ≤ 1000). In the second line you are given n positive integers ai, which are the forces of the magic field acting on each section (1 ≤ ai ≤ 106).
Output
Output two integers separated with a space. They should be the maximum total force of the field acting on three consecutive sections of the wall and the number of the middle section in this segment. It is guaranteed that there is only one answer.
Sample
61 4 4 4 1 1
12 3
题有点长,很好理解。连着三个数的最大值输出,并输出中间数的位置。
#include<cstdio>#include<iostream>using namespace std;int n,a[1001];int main(){ int sum,t,m; while(cin>>n) { for(int i=0;i<n;i++) cin>>a[i]; sum=0; t=0; for(int j=1;j<n-1;j++) { sum=a[j-1]+a[j]+a[j+1]; if(sum>t) { t=sum; m=j; } } cout<<t<<" "<<m+1<<endl; } return 0;}
0 0
- Ural 1910. Titan Ruins: Hidden Entrance
- Ural 1910. Titan Ruins: Hidden Entrance
- URAL 1910. Titan Ruins: Hidden Entrance
- URAL 1910. Titan Ruins: Hidden Entrance
- URAL 1910 Titan Ruins: Hidden Entrance
- ural 1910. Titan Ruins: Hidden Entrance(Titan Ruins系列题目)
- URAL 1910 Titan Ruins: Hidden Entrance 题解与翻译
- URAL 1910 Titan Ruins: Hidden Entrance (阅读理解)
- ural 1917. Titan Ruins: Deadly Accuracy(Titan Ruins系列)
- ural 1915. Titan Ruins: Reconstruction of Bygones
- URAL:1917 Titan Ruins: Deadly Accuracy
- URAL - 1917 Titan Ruins: Deadly Accuracy(水题)
- URAL 1915 Titan Ruins: Reconstruction of Bygones(思路)
- URAL - 1920 Titan Ruins: the Infinite Power of Magic(乱搞)
- URAL 1915 Titan Ruins: Reconstruction of Bygones (栈)
- URAL 1920 Titan Ruins: the Infinite Power of Magic
- ural 1915 Titan Ruins: Repeating Success and Failure
- Ural 1917 Titan Ruins: Better late than killed
- IOS7.0 Xcode5 AutoLayout 备忘录
- 64位win7环境eclipse集成svn后出现Failed to load JavaHL Library的解决办法
- apache
- ajax跨域访问 JQuery 的跨域方法
- 解决Log4J日志文档乱码
- URAL 1910. Titan Ruins: Hidden Entrance
- android 更改webview大小
- Android Studio 1.0 SDK 更新方法
- 用FPM工具生成封装时Allegro弹出Program has encountered a problem的解决方案
- matlab结构(struct)数组
- 使用Android-Universal-Image-Loader异步加载图片遇到的问题
- SQL SERVER类型转换函数
- Eclipse常用快捷键
- No architectures to compile for (ONLY_ACTIVE_ARCH=YES, active arch=x86_64, VALID_ARCHS=i386).