Submission #1156757


Source Code Expand

#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define se second
#define pi 2*acos(0)
#define PI 3.14159265358979323846264338

typedef long long ll;
typedef pair < int , int > pii;
typedef pair < ll , ll > pll;
const int N = 100010;

inline int in() {int x; scanf("%d",&x); return x;}
inline ll lin() {ll x; scanf("%lld",&x); return x;}

int fx[]={1,-1,0,0};
int fy[]={0,0,-1,1};

int inp[N];

int main(){
    int n = in(), c = in(), k = in();

    for(int i = 1; i <= n; i++){
        inp[i] = in();
    }

    sort(inp + 1, inp + n + 1);

    int ans = 0, start = 1;

    while(start <= n){
        int low = start, high = min(start + c - 1, n), mid, ok = start;
        while(low <= high){
            mid = (low + high) >> 1;
            if(inp[start] + k >= inp[min(start + c - 1, n)]){
                low = mid + 1;
                ok = mid;
            }else {
                high = mid - 1;
            }
        }
        ans++;
        start = ok + 1;
    }

    printf("%d\n",ans);
}

Submission Info

Submission Time
Task A - Airport Bus
User Rajib_119
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1107 Byte
Status WA
Exec Time 20 ms
Memory 640 KB

Compile Error

./Main.cpp: In function ‘int in()’:
./Main.cpp:16:39: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
 inline int in() {int x; scanf("%d",&x); return x;}
                                       ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
AC × 2
AC × 7
WA × 5
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 256 KB
in2.txt AC 19 ms 640 KB
in3.txt WA 19 ms 640 KB
in4.txt AC 19 ms 640 KB
in5.txt WA 1 ms 256 KB
in6.txt WA 20 ms 640 KB
in7.txt WA 17 ms 640 KB
in8.txt WA 19 ms 640 KB
sample1.txt AC 1 ms 256 KB
sample2.txt AC 1 ms 256 KB