作业帮 > 综合 > 作业

C++编译体求解啊,学渣伤不起,

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/18 02:48:23
C++编译体求解啊,学渣伤不起,
1009.Line
Total:54 Accepted:10
Time Limit:3sec Memory Limit:256MB
Description
The army of MSY is lining up.The soldiers are numbered from 1 to n,and the i-th soldier has a height of hi.Each soldier wants to know - in the left of him,what is the greatest number of the soldiers taller than him.For solder i,we call this number gi.If there is no soldier taller than soldier i in the left of him,gi is 0.For example,for five soldiers {7,1,3,9,2},g1 is 0 because he is the left-most soldier and there could not be anybody else in the left of him.g2 is 1 because there is only soldier 1 is in the left of him and taller than him.g5 is 4 because there are three soldiers (soldier 1,3 and 4) who are in the left of him and taller than him,so the greatest number is 4.
Now you are asked to write a program to calculate the sum of gi.
Input
Input includes multiple test cases.
The first line is an integer T(T
编译过了,若可以,请给个好评,谢谢
{
int lines;
int num;
cin>>lines;
int soldiers[106]={0};
int results[10]={0};
for (int i =0;i> num;
for (int j=0;j>soldiers[j] ;
for (int t=0;tsoldiers[j])
results[i]++;
}
}
if(1 != num)
results[i]++;
}
for ( i =0;i