Submission #1418742


Source Code Expand

#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <algorithm>
using namespace std;
const int maxn = 100000 + 5;
typedef long long int64;
int n, c, k;
int data[maxn];

int main()
{
  while (scanf("%d%d%d", &n, &c, &k) == 3)
  {
    for (int i = 0; i < n; ++i) scanf("%d", data+i);
    int ans = 0;
    sort(data, data+n);
    int on = 0;
    int earliest = 0;
    for (int i = 0; i < n; ++i)
    {
      int now = data[i];
      if (i == 0 || on == c || earliest + k < now)
      {
        on = 0;
        earliest = 0;
        ++ans;
      }
      if (on == 0) earliest = now;
      ++on;
    }
    cout << ans << endl;
  }
  return 0;
}

Submission Info

Submission Time
Task A - Airport Bus
User baihacker
Language C++14 (GCC 5.4.1)
Score 300
Code Size 720 Byte
Status AC
Exec Time 19 ms
Memory 640 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:17:52: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     for (int i = 0; i < n; ++i) scanf("%d", data+i);
                                                    ^

Judge Result

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