D
|
Jumping
Mario
Input: Standard Input
Output: Standard Output
|
|
Input
The first line of input is an
integer T (T < 30) that
indicates the number of test cases. Each case starts with an integer N (0 < N < 50) that determines the number of walls. The next line
gives the height of the N walls from left to right. Each height is a
positive integer not exceeding 10.
Output
For each case, output the case number followed by 2 integers, total
high jumps and total low jumps, respectively. Look at the sample for exact
format.
Sample Input Output for Sample Input
3
8
1 4 2 2 3 5 3 4
1
9
5
1 2 3 4 5
|
Case 1: 4 2
Case 2: 0 0
Case 3: 4 0
|
Problemsetter: Sohel Hafiz
Special Thanks: Shamim Hafiz
Solution:
#include <stdio.h>
int main(){
static int T, t, W, X, Y, H, L;
scanf("%d", &T);
for(t = 1; t <= T; t++){
H = L = 0;
if(scanf("%d", &W) == 1 && W){
scanf("%d", &X);
while(--W){
scanf("%d", &Y);
if(X < Y) H++;
else if(X > Y) L++;
X = Y;
}
}
printf("Case %d: %d %d\n", t, H, L);
}
return 0;
}
No comments:
Post a Comment