Submission #56170606


Source Code Expand

Copy
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
/* */
int cmp(const void* x, const void* y) {
int a = *(const int*)x, b = *(const int*)y;
return a > b ? -1 : a < b;
}
int N;
int64_t X, Y;
int A[212345];
int B[212345];
int main(void) {
int i;
int ans1, ans2;
int64_t sum;
if (scanf("%d%d%d", &N, &X, &Y) != 3) return 1;
for (i = 0; i < N; i++) {
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>

/* 降順 */
int cmp(const void* x, const void* y) {
	int a = *(const int*)x, b = *(const int*)y;
	return a > b ? -1 : a < b;
}

int N;
int64_t X, Y;
int A[212345];
int B[212345];

int main(void) {
	int i;
	int ans1, ans2;
	int64_t sum;
	if (scanf("%d%d%d", &N, &X, &Y) != 3) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &A[i]) != 1) return 1;
	}
	for (i = 0; i < N; i++) {
		if (scanf("%d", &B[i]) != 1) return 1;
	}
	qsort(A, N, sizeof(*A), cmp);
	qsort(B, N, sizeof(*B), cmp);
	ans1 = ans2 = N;
	sum = 0;
	for (i = 0; i < N; i++) {
		sum += A[i];
		if (sum > X) {
			ans1 = i + 1;
			break;
		}
	}
	sum = 0;
	for (i = 0; i < N; i++) {
		sum += B[i];
		if (sum > Y) {
			ans2 = i + 1;
			break;
		}
	}
	printf("%d\n", ans1 <= ans2 ? ans1 : ans2);
	return 0;
}

Submission Info

Submission Time
Task C - Minimum Glutton
User mikecat
Language C (gcc 12.2.0)
Score 0
Code Size 882 Byte
Status WA
Exec Time 86 ms
Memory 4136 KB

Compile Error

Main.c: In function ‘main’:
Main.c:20:23: warning: format ‘%d’ expects argument of type ‘int *’, but argument 3 has type ‘int64_t *’ {aka ‘long int *’} [-Wformat=]
   20 |         if (scanf("%d%d%d", &N, &X, &Y) != 3) return 1;
      |                      ~^         ~~
      |                       |         |
      |                       int *     int64_t * {aka long int *}
      |                      %ld
Main.c:20:25: warning: format ‘%d’ expects argument of type ‘int *’, but argument 4 has type ‘int64_t *’ {aka ‘long int *’} [-Wformat=]
   20 |         if (scanf("%d%d%d", &N, &X, &Y) != 3) return 1;
      |                        ~^           ~~
      |                         |           |
      |                         int *       int64_t * {aka long int *}
      |                        %ld

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 250
Status
AC × 3
AC × 14
WA × 16
Set Name Test Cases
Sample sample00.txt, sample01.txt, sample02.txt
All sample00.txt, sample01.txt, sample02.txt, testcase00.txt, testcase01.txt, testcase02.txt, testcase03.txt, testcase04.txt, testcase05.txt, testcase06.txt, testcase07.txt, testcase08.txt, testcase09.txt, testcase10.txt, testcase11.txt, testcase12.txt, testcase13.txt, testcase14.txt, testcase15.txt, testcase16.txt, testcase17.txt, testcase18.txt, testcase19.txt, testcase20.txt, testcase21.txt, testcase22.txt, testcase23.txt, testcase24.txt, testcase25.txt, testcase26.txt
Case Name Status Exec Time Memory
sample00.txt AC 1 ms 1636 KB
sample01.txt AC 1 ms 1732 KB
sample02.txt AC 1 ms 1632 KB
testcase00.txt AC 83 ms 3920 KB
testcase01.txt AC 83 ms 3996 KB
testcase02.txt AC 83 ms 3980 KB
testcase03.txt AC 83 ms 3920 KB
testcase04.txt WA 80 ms 3928 KB
testcase05.txt WA 84 ms 4136 KB
testcase06.txt WA 80 ms 3856 KB
testcase07.txt WA 83 ms 4128 KB
testcase08.txt WA 79 ms 3928 KB
testcase09.txt WA 83 ms 3940 KB
testcase10.txt WA 75 ms 3832 KB
testcase11.txt WA 83 ms 4092 KB
testcase12.txt WA 79 ms 3988 KB
testcase13.txt WA 83 ms 3976 KB
testcase14.txt WA 81 ms 4000 KB
testcase15.txt WA 83 ms 3984 KB
testcase16.txt AC 67 ms 3908 KB
testcase17.txt AC 74 ms 3956 KB
testcase18.txt AC 71 ms 4020 KB
testcase19.txt AC 73 ms 4080 KB
testcase20.txt AC 67 ms 3896 KB
testcase21.txt AC 73 ms 4088 KB
testcase22.txt AC 66 ms 3812 KB
testcase23.txt WA 73 ms 3960 KB
testcase24.txt WA 84 ms 3948 KB
testcase25.txt WA 83 ms 3944 KB
testcase26.txt WA 86 ms 3992 KB


2024-08-01 (Thu)
07:36:54 +09:00