A. Reconnaissance 2
来源:互联网 发布:mac 梦幻西游手游网页 编辑:程序博客网 时间:2024/05/29 01:51
n soldiers stand in a circle. For each soldier his height ai is known. A reconnaissance unit can be made of such two neighbouringsoldiers, whose heights difference is minimal, i.e. |ai?-?aj| is minimal. So each of them will be less noticeable with the other. Output any pair of soldiers that can form a reconnaissance unit.
The first line contains integer n (2?≤?n?≤?100) — amount of soldiers. Then follow the heights of the soldiers in their order in the circle —n space-separated integers a1,?a2,?...,?an (1?≤?ai?≤?1000). The soldier heights are given in clockwise or counterclockwise direction.
Output two integers — indexes of neighbouring soldiers, who should form a reconnaissance unit. If there are many optimum solutions, output any of them. Remember, that the soldiers stand in a circle.
5
10 12 13 15 10
5 1
4
10 20 30 40
1 2
/* ***********************************************
Author :
Created Time :2015/6/14 12:18:25
File Name :7.cpp
************************************************ */
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <iomanip>
#include <list>
#include <deque>
#include <stack>
#define ull unsigned long long
#define ll long long
#define mod 90001
#define INF 1<<30
#define maxn 10000+10
#define cle(a) memset(a,0,sizeof(a))
const ull inf = 1LL << 61;
const double eps=1e-5;
using namespace std;
bool cmp(int a,int b){
return a>b;
}
int a[maxn];
int main()
{
#ifndef ONLINE_JUDGE
//freopen("in.txt","r",stdin);
#endif
int n;
int x,y;
while(cin>>n){
for(int i=1;i<=n;i++)
cin>>a[i];
a[n+1]=a[1];
int Min=INF;
for(int i=2;i<=n+1;i++){
if(abs(a[i]-a[i-1])<Min){
Min=abs(a[i]-a[i-1]);
x=i;y=i-1;
if(x>n)x=1;
}
}
cout<<y<<" "<<x<<endl;
}
return 0;
}
- A. Reconnaissance 2
- A. Reconnaissance 2
- CodeForces 34A Reconnaissance 2
- CODEFORCES, 34A,Reconnaissance 2
- A. Reconnaissance
- A - Reconnaissance 2 士兵 立正啦…
- 【水数组】#34 A. Reconnaissance 2
- Codeforce 34A-Reconnaissance 2(水)
- 【水排序】#32 A. Reconnaissance
- Reconnaissance 2(水题)
- Reconnaissance
- Directory traversal as a reconnaissance tool
- Review: SANS SEC550 Information Reconnaissance
- Testing: Conduct search engine discovery/reconnaissance for information leakage (OTG-INFO-001)
- (*a)[2] *a[2]
- a = a ?:2;
- 矩阵求A^k,A+A^2+A^3+……A^k
- (a+b)/2与a+(b-a)/2的区别
- A. Worms Evolution
- A. Reconnaissance
- 重新认识——CSS Position定位
- A. What is for dinner?
- 设计模式:建造者模式(Builder)
- A. Reconnaissance 2
- A. Shell Game
- A. Extra-terrestrial Intelligence
- A. Towers
- A. Find Color
- Python 高亮设置(转)
- 记录统计编程的插件 wakatime
- BestCoder Round #47 ($) HDU 5280 Senior\'s Array
- HDU 5326 Work