# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
3318 | yys1221 | 두 섬간의 연결 (kriii1_2) | C11 | 32 ms | 1360 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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);
printf("\n");
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |