D - Non-decreasing
题目链接:Non-decreasing
题目大意:
给一个长度为
数据范围:
解题思路:
这道题比赛的时候没想出来。C题5分钟写完就挂机了。。 比赛完了之后看了别的代码瞬间理解。
其实如果这个题
AC代码:
/********************************************
*Author* :ZZZZone
*Created Time* : 一 12/11 20:46:20 2017
* Ended Time* : 一 12/11 21:04:29 2017
*********************************************/
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<iostream>
using namespace std;
int n;
int a[55];
int main(){
scanf("%d", &n);
int p = 0;
for(int i = 1; i <= n; i++){
scanf("%d", &a[i]);
if(abs(a[i]) >= abs(a[p])) p = i;
}
printf("%d\n", 2 * n - 1);
for(int i = 1; i <= n; i++) printf("%d %d\n", p, i);
if(a[p] > 0) for(int i = 1; i < n; i++) printf("%d %d\n", i, i + 1);
else for(int i = n; i > 1; i--) printf("%d %d\n", i, i - 1);
return 0;
}