Submission #4805959


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

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

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

Submission Info

Submission Time
Task D - Katana Thrower
User herp_sy
Language C (GCC 5.4.1)
Score 0
Code Size 681 Byte
Status WA
Exec Time 29 ms
Memory 1276 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(a,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:19:2: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&N,&H);
  ^
./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",&a[i],&b[i]);
                              ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 400
Status
AC × 3
WA × 1
AC × 15
WA × 9
Set Name Test Cases
Sample a01, a02, a03, a04
All a01, a02, a03, a04, b05, b06, b07, b08, b09, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20, b21, b22, b23, b24
Case Name Status Exec Time Memory
a01 WA 1 ms 128 KB
a02 AC 1 ms 128 KB
a03 AC 1 ms 128 KB
a04 AC 1 ms 128 KB
b05 AC 1 ms 128 KB
b06 WA 27 ms 1148 KB
b07 AC 1 ms 128 KB
b08 WA 27 ms 1148 KB
b09 AC 1 ms 128 KB
b10 WA 1 ms 128 KB
b11 AC 1 ms 128 KB
b12 AC 1 ms 128 KB
b13 AC 17 ms 1148 KB
b14 WA 17 ms 1148 KB
b15 AC 17 ms 1148 KB
b16 AC 17 ms 1148 KB
b17 AC 29 ms 1276 KB
b18 WA 26 ms 1276 KB
b19 AC 24 ms 1276 KB
b20 WA 25 ms 1276 KB
b21 WA 26 ms 1276 KB
b22 AC 29 ms 1276 KB
b23 AC 1 ms 128 KB
b24 WA 1 ms 252 KB