회원가입
로그인
Toggle navigation
문제
문제
전체 문제
문제 출처
단계별로 풀어보기
알고리즘 분류
추가된 문제
문제 순위
문제
푼 사람이 한 명인 문제
아무도 못 푼 문제
최근 제출된 문제
최근 풀린 문제
랜덤
출처
ICPC
Olympiad
한국정보올림피아드
한국정보올림피아드시․도지역본선
전국 대학생 프로그래밍 대회 동아리 연합
대학교 대회
카카오 코드 페스티벌
Coder's High
ICPC
Regionals
World Finals
Korea Regional
Africa and the Middle East Regionals
Europe Regionals
Latin America Regionals
North America Regionals
South Pacific Regionals
문제집
대회
1
채점 현황
랭킹
게시판
그룹
더 보기
재채점 기록
블로그
강의
실험실
도움말
BOJ Stack
BOJ Book
전체
공지
자유
질문
오타/오역/요청
게시판 공지
홍보
업데이트
solved.ac
글쓰기
질문 도움말
자주묻는 질문
2108번 47%에서 틀립니다 예제랑 찾아본 반례는 다 잘됩니다 ㅠ
2108번 - 통계학
guswhd903
1년 전
0
어디에서 틀렸는지 모르겠습니다 예제랑 찾아본반례는 잘되는것같은데 잘모르겠습니다.. 도와주세요
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <math.h> int size = 0; int heap[1000001]; int number = 0; int counting[10100]; double pi = 0; int main() { scanf("%d", &size); for (int i = 0;i < size;i++) { scanf("%d", &heap[i]); pi += heap[i]; } pi /= size; for (int i = 1; i < size; i++) { int child = i; do { int root = (child - 1) / 2; if (heap[root] < heap[child]) { int temp = heap[root]; heap[root] = heap[child]; heap[child] = temp; } child = root; } while (child != 0); } for (int i = size - 1; i >= 0; i--) { int temp = heap[0]; heap[0] = heap[i]; heap[i] = temp; int root = 0; int child = 1; do { child = 2 * root + 1; if (heap[child] < heap[child + 1] && child < i - 1) { child++; } if (heap[root] < heap[child] && child < i) { int temp = heap[root]; heap[root] = heap[child]; heap[child] = temp; } root = child; } while (child < i); } int temp = 0; for (int i = 0;i < size;i++) { if(heap[i] <=0) counting[-heap[i]]++; else { counting[heap[i]+4000]++; } } int a = 0; int value = 0; for (int i = 0; i < 8001; i++) { if (temp < counting[i] && counting[i]>0) { temp = counting[i]; a = 0; if (i <= 4000) { value = -i; } else { value = i - 4000; } } else if(temp == counting[i]&& counting[i] > 0) if (i <= 4000 && value < -i&&a == 0) { temp = counting[i]; value = -i; a = 1; } else if (i > 4000 && value < i - 4000 && a == 0) { temp = counting[i]; value = i - 4000; a = 1; } } pi = floor(pi + 0.5); printf("%0.0lf\n", pi); printf("%d\n", heap[size / 2]); printf("%d\n", value); printf("%d\n", heap[size - 1] - heap[0]); return 0; }
댓글을 작성하려면
로그인
해야 합니다.
guswhd903 1년 전
어디에서 틀렸는지 모르겠습니다 예제랑 찾아본반례는 잘되는것같은데 잘모르겠습니다.. 도와주세요