Horror Dash
2 مشترك
صفحة 1 من اصل 1
Horror Dash
It is that time of the year again! Colorful balloons and brightly colored banners spread out over your entire neighborhood for just this one occasion. It is the annual clown's festival at your local school. For the first time in their lives, students from the school try their hands at being the best clown ever. Some walk on long poles, others try to keep a crowd laughing for the day with stage comedy, while others still try out their first juggling act - some 'master clowns' even teach these juggling tricks to visitors at the festival.
As part of the festival, there is a unique event known as the "Horror Dash". At this event, N (1≤N≤100) students dressed in the scariest costumes possible start out in a race to catch a poor clown running on the same track. The clown trips over, loses his mind, and does all sorts of comical acts all while being chased round and round on the track. To keep the event running for as long as possible, the clown must run fast enough not to be caught by any of the scary creatures. However, to keep the audience on the edge of their seats, the clown must not run too fast either. This is where you are to help. Given the speed of every scary creature, you are to find out the minimum speed that the clown must maintain so as not to get caught even if they keep on running forever.
Input
The first line of input contains a single integer T (T≤50), the number of test cases. This line is followed by T input cases. Each input case is on a single line of space-separated integers. The first of these integers is N, the number of students acting as scary creatures. The rest of the line has N more integers, c0, c1, ..., cn, each representing the speed of a creature in meters per second (1≤ci≤10000 for each i). You can assume that they are always running in the same direction on the track.
Output
There should be a single line of output for each test case, formatted as “Case c: s”. Here, c represents the serial number of the input case, starting with 1, while s represents the required speed of the clown, in meters per second.
As part of the festival, there is a unique event known as the "Horror Dash". At this event, N (1≤N≤100) students dressed in the scariest costumes possible start out in a race to catch a poor clown running on the same track. The clown trips over, loses his mind, and does all sorts of comical acts all while being chased round and round on the track. To keep the event running for as long as possible, the clown must run fast enough not to be caught by any of the scary creatures. However, to keep the audience on the edge of their seats, the clown must not run too fast either. This is where you are to help. Given the speed of every scary creature, you are to find out the minimum speed that the clown must maintain so as not to get caught even if they keep on running forever.
Input
The first line of input contains a single integer T (T≤50), the number of test cases. This line is followed by T input cases. Each input case is on a single line of space-separated integers. The first of these integers is N, the number of students acting as scary creatures. The rest of the line has N more integers, c0, c1, ..., cn, each representing the speed of a creature in meters per second (1≤ci≤10000 for each i). You can assume that they are always running in the same direction on the track.
Output
There should be a single line of output for each test case, formatted as “Case c: s”. Here, c represents the serial number of the input case, starting with 1, while s represents the required speed of the clown, in meters per second.
Sample Input | Sample Output |
2 5 9 3 5 2 6 1 2 | Case 1: 9 Case 2: 2 |
feras_kassar- الجنس :
عدد المساهمات : 78
السٌّمعَة : 1
تاريخ التسجيل : 19/02/2014
رد: Horror Dash
عم يحطلي runtime error فشو المشكلة بعد ازنكن ؟؟
- الكود:
#include<iostream>
using namespace::std;
int main()
{
int x,i,n,k=0,j=0,max;
int a[100];
char c=' ';
cin>>n;
if (n<=50){
for(i=1;i<=n;i++)
{
while(c!='\n')
{
cin>>x;
a[j]=x;
j=j+1;
cin.get(c);
}
max=a[0];
for(k=0;k<j;k++)
if(a[k]>max)
max=a[k];
cout<<"case "<<i<<": "<<max<<endl;
c=' ';
for (k=0;k<j;k++)
a[k]=0;
}
}
}
hayan.narsh- الجنس :
عدد المساهمات : 3
السٌّمعَة : 0
تاريخ التسجيل : 19/02/2014
رد: Horror Dash
ضمن كل سطر الرقم الأول هو عدد الأرقام بالسطر
أنت عم تقرأ هالرقم و ضيفه للمصفوفة
بالتالي اذا كان عندك حالة 100 رقم
صارو 101 رقم و أنت حاجز المصفوفة لـ 100 عنصر
بالتالي عم يتجاوز المصفوفة و يعطي run time error
أنت عم تقرأ هالرقم و ضيفه للمصفوفة
بالتالي اذا كان عندك حالة 100 رقم
صارو 101 رقم و أنت حاجز المصفوفة لـ 100 عنصر
بالتالي عم يتجاوز المصفوفة و يعطي run time error
feras_kassar- الجنس :
عدد المساهمات : 78
السٌّمعَة : 1
تاريخ التسجيل : 19/02/2014
صفحة 1 من اصل 1
صلاحيات هذا المنتدى:
لاتستطيع الرد على المواضيع في هذا المنتدى