반응형
#include#define MAX 100000 int N, M; int answerN; int arr_n[MAX + 1]; int arr_m[MAX + 1]; int getAbs(int n, int m){ return n - m > 0 ? n - m : m - n; } struct data{ int i; int tem = 10000000; int closest = -1; int distan = -1; int min=-1; int bf(int x, int y) { printf("\n(%d,%d) ", x, y); for (i = x; i <= N; i++) { distan = getAbs(arr_n[i], arr_m[y]); if (distan < tem) { tem = distan; closest = i; printf("d: %d, c: %d ", distan, closest); min = distan; } } return min; } } que[MAX + 1]; void main(){ int i, j; int T; int distan = -1; int max = 0; int index = 1; scanf("%d", &T); for (i = 0; i < T; i++) { answerN = 0; scanf("%d %d", &N, &M); for (i = 1; i <= N; i++){ scanf("%d", &arr_n[i]); } for (i = 1; i <= M; i++){ scanf("%d", &arr_m[i]); distan = que[i].bf(index, i); printf("-=-->%d", distan); if (distan > max){ max = distan; } } printf("Answer : %d", max); scanf("%d", index); } } 데이터 1 3 4 2 3 6 1 5 7 8 1 4 5 2 4 6 8 1 5 7 9 10 1 6 7 1 10 15 18 19 35 9 13 16 17 18 24 41 1 3 2 6 7 16 15 40
반응형
'etc' 카테고리의 다른 글
tc1 (0) | 2015.05.10 |
---|---|
Links (0) | 2015.05.10 |
so dynamic loading (0) | 2015.04.04 |
Coursera (0) | 2015.02.23 |
api design (0) | 2015.02.15 |