top of page

소스 코드 제출

공개·회원 52명

20250418

#include<stdio.h>

int main()

{

int n, arr[3001]={}, t[3001]={},a[3001]={}, x=0,i=1,j=1,Tr=0, min=10000000, temp[2]={},wich=0;

scanf("%d", &n);

i=1;

while(i<=n)

{

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

i++;

}

i=1;

while(i<=n)

{

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

i++;

}

i=1;

printf("1\n");

while(i<n)

{

min = i;

j = i;

while(j<=n)

{

if (t[min]>t[j])

{

min = j;

}

j++;

}

temp[0] = arr[i];

temp[1] = t[i];

arr[i] = arr[min];

t[i] = t[min];

arr[min] = temp[0];

t[min] = temp[1];

i++;

}

printf("2\n");

i = 1;

while(i<=n)

{

if (wich>arr[i])

{

temp[0] = wich-arr[i];

}

else

{

temp[0] = (wich-arr[i])*-1;

}

if (temp[0]>t[i])

{

x+=temp[0];

temp[1] = temp[0];

wich += temp[0];

printf("true %2d, %2d, %2d, %2d\n", temp[0], x, i, wich);

}

else

{

x+=temp[0]+(t[i]-temp[0]);

temp[1] = temp[0]+(t[i]-temp[0]);

wich+=temp[0];

printf("false %2d, %2d, %2d, %2d\n", temp[0]+(t[i]-temp[0]), x, i, wich);

}

j=1;

while(j<=n)

{

t[j]-= temp[1];

if (t[j] < 0)

{

t[j] = 0;

}

j++;

}

i++;

}

x+=wich;

printf("%d, %d", x, wich);

}

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