Submission #3318

#TimeUsernameProblemLanguageResultExecution timeMemory
3318yys1221두 섬간의 연결 (kriii1_2)C11
0 / 1
32 ms1360 KiB
#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 timeMemoryGrader output
Fetching results...