Submission #1291279


Source Code Expand

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

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

int main(void){
    int n, a[100], i, max;
    scanf("%d", &n);
    for(i = 0; i < n; i++) scanf("%d", &a[i]);
    qsort(a, n, sizeof(int), comp);
    max = a[n-1];
    n--;
    while(1){
        if(max != a[n]){
            printf("%d\n", a[n]);
            break;
        }
        n--;
    }
    return 0;
}

Submission Info

Submission Time
Task B - 心配性な富豪、ファミリーレストランに行く。
User mosmos21
Language C (GCC 5.4.1)
Score 100
Code Size 423 Byte
Status AC
Exec Time 1 ms
Memory 128 KB

Compile Error

./Main.c: In function ‘main’:
./Main.c:12:30: 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 (*)(int *, int *)’
 extern void qsort (void *__base, size_t __nmemb, size_t __size,
             ^
./Main.c:10:5: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ^
./Main.c:11:28: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
     for(i = 0; i < n; i++) scanf("%d", &a[i]);
                            ^

Judge Result

Set Name All
Score / Max Score 100 / 100
Status
AC × 18
Set Name Test Cases
All random_1.txt, random_10.txt, random_2.txt, random_3.txt, random_4.txt, random_5.txt, random_6.txt, random_7.txt, random_8.txt, random_9.txt, sample_1.txt, sample_2.txt, sample_3.txt, small_1.txt, small_2.txt, small_3.txt, small_4.txt, small_5.txt
Case Name Status Exec Time Memory
random_1.txt AC 1 ms 128 KB
random_10.txt AC 1 ms 128 KB
random_2.txt AC 1 ms 128 KB
random_3.txt AC 1 ms 128 KB
random_4.txt AC 1 ms 128 KB
random_5.txt AC 1 ms 128 KB
random_6.txt AC 1 ms 128 KB
random_7.txt AC 1 ms 128 KB
random_8.txt AC 1 ms 128 KB
random_9.txt AC 1 ms 128 KB
sample_1.txt AC 1 ms 128 KB
sample_2.txt AC 1 ms 128 KB
sample_3.txt AC 1 ms 128 KB
small_1.txt AC 1 ms 128 KB
small_2.txt AC 1 ms 128 KB
small_3.txt AC 1 ms 128 KB
small_4.txt AC 1 ms 128 KB
small_5.txt AC 1 ms 128 KB