Submission #2179114


Source Code Expand

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

int a[100005] ;

int com ( const void* a, const void* b ) {
    int * pa = (int*) a ;
    int * pb = (int*) b ;
    return *pa - *pb ;
}

int main () {
    int n, c, k, i, min, tem, result ;
    scanf ( "%d %d %d", &n, &c, &k ) ;
    for ( i = 0 ; i < n ; i++ ) {
        scanf ( "%d", &a[i] ) ;
    }
    qsort ( a, n, sizeof (int), com ) ;
    result = 0 ;
    tem = 1 ;
    for ( i = 1 ; i < n ; i++ ) {
        if ( a[i] - a[i-1] <= c ) {
            tem++ ;
        }
        else {
            result++ ;
        }
    }
    result += tem/c ;
    if ( tem % c != 0 ) {
        result++ ;
    }
    printf ( "%d\n", result ) ;
    return 0 ;
}

Submission Info

Submission Time
Task A - Airport Bus
User vjudge2
Language C++14 (GCC 5.4.1)
Score 0
Code Size 727 Byte
Status WA
Exec Time 24 ms
Memory 892 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:16:38: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf ( "%d %d %d", &n, &c, &k ) ;
                                      ^
./Main.cpp:18:31: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf ( "%d", &a[i] ) ;
                               ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
AC × 2
AC × 6
WA × 6
Set Name Test Cases
Sample sample1.txt, sample2.txt
All sample1.txt, sample2.txt, in1.txt, in2.txt, in3.txt, in4.txt, in5.txt, in6.txt, in7.txt, in8.txt, sample1.txt, sample2.txt
Case Name Status Exec Time Memory
in1.txt AC 1 ms 128 KB
in2.txt WA 24 ms 892 KB
in3.txt WA 24 ms 892 KB
in4.txt AC 24 ms 892 KB
in5.txt WA 1 ms 128 KB
in6.txt WA 24 ms 892 KB
in7.txt WA 21 ms 892 KB
in8.txt WA 24 ms 892 KB
sample1.txt AC 1 ms 128 KB
sample2.txt AC 1 ms 128 KB