早教吧作业答案频道 -->其他-->
C++编译体求解啊,学渣伤不起,1009.LineTotal:54Accepted:10TimeLimit:3secMemoryLimit:256MBDescriptionThearmyofMSYisliningup.Thesoldiersarenumberedfrom1ton,andthei-thsoldierhasaheightofhi.Eachsoldierwantstoknow-i
题目详情
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
▼优质解答
答案和解析
编译过了,若可以,请给个好评,谢谢{ 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]) result...
看了C++编译体求解啊,学渣伤不起...的网友还看了以下:
LED蓝光、LED红光波长长短对人体伤害的程度大小正题:①蓝光470纳米和蓝光410纳米那种对人体 2020-05-15 …
苏联解体前是社会主义,解体后的的几个国家(包括俄罗斯在内)就都变资本主义了?救命啊 我思维混乱啊. 2020-05-16 …
关于中温焦油有对人体的伤害我今年17岁在油库做了两年中温焦油人家都说做我怎么小做这个对身体伤害很大 2020-05-17 …
那你都是买的什么装备分解晶体的啊?他那些都是绿色的在就是蓝色的一般都分解无色了别的不多啊无色都狠便 2020-05-17 …
我笑爆了,这个词,我笑了几天大河向东流啊这里的楼主解大手啊拉不出屎一声吼啊!吼不出屎用手抠!风风火 2020-06-21 …
英语翻译joltingmeoutofreverie啥意思啊?joltingmeoutofmysad 2020-06-27 …
dd胶是什么化学物质?与什么起化学反应被降解?dd胶用于墙体的工程!但dd胶干燥后,怎样能够去除, 2020-07-04 …
酵母菌的线粒体在饥饿和光照等条件下损伤后发生特异性的“自噬”现象.这是由于损伤后的线粒体产生一种外 2020-07-12 …
吾何以天下为哉!有哪些语法点?语法点又如何解释?下周一就要上台讲了,文言文是硬伤啊.T^T 2020-07-15 …
就是求空心圆柱的体积,有个例题不理解啊π*R^2*h-π*r^2*h=π*h(R+r)(R-r)R为 2020-11-28 …