Submission #1753476


Source Code Expand

Copy
#include <stdio.h>
#include <stdlib.h>

int comp(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int main(void) {
    int n, c, i, j, count;
    int l[100000];
    scanf("%d%d", &n, &c);
    for (i = 0; i < n; i++) {
        scanf("%d", l + i);
    }
    
    qsort(l, n, sizeof(int), comp);
    i = n - 1, j = 0;
    while (j <= i) {
        if (l[i] + l[j] < c) {
            i--;
            j++;
            count++;
        } else if (l[i] <= c) {
            i--;
            count++;
        }
    }
    printf("%d\n", count);
    return 0;
}

Submission Info

Submission Time
Task C - 収納
User madman6
Language C (GCC 5.4.1)
Score 0
Code Size 601 Byte
Status
Exec Time 25 ms
Memory 892 KB

Compile Error

./Main.c: In function ‘main’:
./Main.c:11:5: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &n, &c);
     ^
./Main.c:13:9: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", l + i);
         ^

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01.txt, sample_02.txt, sample_03.txt
All 0 / 300 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
01.txt 25 ms 892 KB
02.txt 25 ms 892 KB
03.txt 21 ms 892 KB
04.txt 24 ms 892 KB
05.txt 19 ms 892 KB
06.txt 12 ms 764 KB
07.txt 14 ms 764 KB
08.txt 23 ms 892 KB
09.txt 23 ms 892 KB
10.txt 12 ms 764 KB
11.txt 25 ms 892 KB
12.txt 25 ms 892 KB
13.txt 21 ms 892 KB
sample_01.txt 1 ms 128 KB
sample_02.txt 1 ms 128 KB
sample_03.txt 1 ms 128 KB