C++编译体求解啊,学渣伤不起,
holyblue2022-10-04 11:39:541条回答
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
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
已提交,审核后显示!提交回复
共1条回复
- qiushi520 共回答了21个问题
|采纳率95.2% - 编译过了,若可以,请给个好评,谢谢
{
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 - 1年前
相关推荐
大家在问
- 1读某地气温和降水逐月分布图,回答题。
- 2小王和小刘做游戏,将一枚普通的骰子抛掷两次,求出两个点数之和,约定和是偶数时小王得1分,和是奇数时小刘得1分.小莉过来看
- 3从特殊到一般得到的数学定理有哪些?
- 4be hurt=get hurt吗
- 5verilog语法`define HH 15`define HL 5`HH-`HL+1{1'b0} 是说11位全0吗?
- 6“清明前后种瓜点豆”这句农谚的意思是?
- 725/9÷5/4÷4/5简便运算
- 8化简sin^2 1度+sin^2 2度+sin^2 3度+.+sin^2 89度
- 9You have reached the maximum number of free trial calls以下文章是
- 10根据中国近现代史谈谈国庆盛典的观后感(2000字)
- 11写英语作文 我有一个梦想不用太多 单词是初二的基础
- 12pcl5(g) pcl3(g)+cl2(g).测得平衡混合气体的压强为p1 ,此时再向反应器中通入amolpcl5,相同
- 13请问it可以代指复数名词吗?如眼镜
- 14我学会了帮助他人为题写一篇英语作文
- 15《十三岁的际遇》第九段赏析从各种修辞手法,描写方法,整段的内容,作者想表达的情感,和自己的感悟来回答,不少于300字