Submission #5021894


Source Code Expand

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

// qsort(array, size, sizeof(int),comp);
int comp(const int *a,const int *b){
	return (*b - *a);
}

int main(int argc, char const *argv[])
{
	int n,*d;
	int cnt = 1;
	scanf("%d",&n);
	d = (int *)malloc(sizeof(int) * n);
	for (int i = 0; i < n; ++i)	scanf("%d",&d[i]);
	qsort(d,n,sizeof(int),comp);
	for (int i = 1; i < n; ++i)
	{
		if(d[i - 1] > d[i])	++cnt;	
	}
	printf("%d\n", cnt);
	return 0;
}

Submission Info

Submission Time
Task B - Kagami Mochi
User herp_sy
Language C (GCC 5.4.1)
Score 200
Code Size 606 Byte
Status AC
Exec Time 1 ms
Memory 128 KB

Compile Error

./Main.c: In function ‘main’:
./Main.c:23:24: warning: passing argument 4 of ‘qsort’ from incompatible pointer type [-Wincompatible-pointer-types]
  qsort(d,n,sizeof(int),comp);
                        ^
In file included from ./Main.c:2:0:
/usr/include/stdlib.h:765:13: note: expected ‘__compar_fn_t {aka int (*)(const void *, const void *)}’ but argument is of type ‘int (*)(const int *, const int *)’
 extern void qsort (void *__base, size_t __nmemb, size_t __size,
             ^
./Main.c:20:2: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ^
./Main.c:22:30: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
  for (int i = 0; i < n; ++i) scanf("%d",&d[i]);
                              ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 3
AC × 13
Set Name Test Cases
Sample a01, a02, a03
All a01, a02, a03, b04, b05, b06, b07, b08, b09, b10, b11, b12, b13
Case Name Status Exec Time Memory
a01 AC 1 ms 128 KB
a02 AC 1 ms 128 KB
a03 AC 1 ms 128 KB
b04 AC 1 ms 128 KB
b05 AC 1 ms 128 KB
b06 AC 1 ms 128 KB
b07 AC 1 ms 128 KB
b08 AC 1 ms 128 KB
b09 AC 1 ms 128 KB
b10 AC 1 ms 128 KB
b11 AC 1 ms 128 KB
b12 AC 1 ms 128 KB
b13 AC 1 ms 128 KB