답안 #28650

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
28650 2017-07-16T08:23:46 Z 탕탕탕! 핑거팁 니 맘을 겨눌게~(#1190, cls327, archane5276, ly0829) 포도주 시음 (FXCUP2_wine) C
컴파일 오류
0 ms 0 KB
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int wine[300000];

int partition(int low, int high) {
	int i, j, pivotitem, temp;
	i = rand() % ((high - low) + 1) + low;
	temp = wine[low];
	wine[low] = wine[i];
	wine[i] = temp;
	pivotitem = wine[low];
	j = low;
	for (i = low + 1; i <= high; i++) {
		if (wine[i] <= pivotitem) {
			j++;
			temp = wine[i];
			wine[i] = wine[j];
			wine[j] = temp;
		}
	}
	temp = wine[low];
	wine[low] = wine[j];
	wine[j] = temp;
	
	return j;
}
void quicksort(int low, int high) {
	int p;
	if (high > low) {
		p = partition(low, high);
		quicksort(low, p - 1);
		quicksort(p + 1, high);
	}
}
int main() {
	int N, K, i, first = 0, end = 1;
	long long int flavor = 0;
	scanf("%d %d", &N, &K);
	for (i = 0; i < N; i++)
		scanf("%d", &wine[i]);
	srand(tiem(NULL));
	quicksort(0, N-1);
	for (i = 0; i < K; i = i + 2) {
		if (i == 0) {
			flavor = wine[N - end];
			end++;
			continue;
		}
		flavor += wine[N - end] - wine[0 + first];
		end++;
		first++;	
	}
	printf("%lld", flavor);
	return 0;
}

Compilation message

wine.c: In function 'main':
wine.c:42:8: warning: implicit declaration of function 'tiem' [-Wimplicit-function-declaration]
  srand(tiem(NULL));
        ^
wine.c:39:2: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &N, &K);
  ^
wine.c:41:3: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &wine[i]);
   ^
/tmp/ccE4oO67.o: In function `main':
wine.c:(.text.startup+0x60): undefined reference to `tiem'
collect2: error: ld returned 1 exit status