#include <stdio.h>
#include <stdlib.h>
int main(){
int number, i, j, temp, num_total, map[100000] = {0};
int possible_case = 0, total_case = 0;
int left, right;
scanf("%d", &num_total);
number = num_total-1;
for(i=0;i<number;i++){
scanf("%d", &temp);
map[temp-1] = 1;
left = 0;
right = 0;
for(j=temp-2;j>=0;j--){
if(map[j]==0)
break;
left++;
}
for(j=temp;j<num_total;j++){
if(map[j]==0)
break;
right++;
}
if(left==0&& right==0){
possible_case++;
total_case++;
}else{
possible_case+=(right+1)*(left+1);
total_case+=((right+left+1)*(right+left+2)/2-(left+1)*left/2)*(left+1)-left*(left+1)*(right+1)/2;
}
printf("%d %d\n", possible_case, total_case);
if(i!=number-1)
printf("\n");
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
48 ms |
1356 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |