大家看看这道题,我感觉我没有做错!为什么总是wrong anwser 呢!
Number sequence
--------------------------------------------------------------------------------
Time limit: 1sec. Submitted: 31
Memory limit: 64M Accepted: 8
Source : SCU Programming Contest 2006 Final
--------------------------------------------------------------------------------
Given a number sequence which has N element(s), please calculate the number of different collocation for three number Ai, Aj, Ak, which satisfy that Ai < Aj > Ak and i < j < k.
Input
The first line is an integer N (N <= 50000). The second line contains N integer(s): A1, A2, ..., An(0 <= Ai <= 32768).
Output
There is only one number, which is the the number of different collocation.
Sample Input
5
1 2 3 4 1
Sample Output
6
#include <stdio.h>
#define N 1000
int main(void)
{
long s;
int str1[N], i, j, k = 1, num = 0;
scanf("%ld", &s);
for(i = 0;i < s;i ++)
scanf("%d", &str1[i]);
for(k = 1;k < s - 1;k ++)
for(i = 0;i < k;i ++)
for(j = k + 1;j < s;j ++)
{
if(str1[k] > str1[i]&&str1[k] >str1[j])
num ++;
}
printf("%d\n", num);
return 0;
}