top of page

소스 코드 제출

공개·회원 52명

12341234

#include <stdio.h>

#include <stdlib.h>

int main()

{

int b[10000]={};

int n,i,hol=0,k=0,count=0;

scanf("%d",&n);

for(i=0;i<n;i++) {

scanf("%d",&b[i]);

if(b[i]%2==1) {

hol++;

}

}

for(i=0;i<n;i++) {

if(i<hol) {

if(b[i]%2==0 && b[i]!=-1) {

b[i]=-1;

count += abs((hol+k) - i);

hol--;

}

}

else if(i>=hol) {

if(b[i]%2==1 && b[i]!=-1) {

b[i]=-1;

count += abs((hol+k) - i);

hol++;

}

}

}

printf("%d",count);

}

3회 조회
주소 : 경기도 용인시 광교중앙로 302 블루 스퀘어 602호
연락처 : 031) 216 - 1546 ,     031) 215 - 1546
사업자등록번호 : 465-92-00916
​학원 등록 제 4603호
bottom of page