Submission #1156746


Source Code Expand

#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#define int long long
#define uint unsigned long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
using namespace std;

signed main()
{
	int N, C, K;
	cin >> N >> C >> K;
	vector<int> T;
	for (int i = 0; i < N; i++)
	{
		int t;
		cin >> t;
		T.push_back(t);
	}

	sort(T.begin(), T.end());
	T.push_back(-1);

	int time = T[0];
	int c = 0;
	int bus = 0;
	for (int i = 0; i < N; i++)
	{
		if (T[i] > time + K)
		{
			bus++;
			c = 0;
			time = T[i];
		}
		if (T[i] <= time + K)
		{
			c++;
		}
		if (c >= C)
		{
			bus++;
			c = 0;
			time = T[i + 1];
		}
		else if (i == N - 1)
		{
			bus++;
		}
	}

	cout << bus << endl;
}

Submission Info

Submission Time
Task A - Airport Bus
User y_kawano
Language C++14 (GCC 5.4.1)
Score 300
Code Size 922 Byte
Status AC
Exec Time 47 ms
Memory 1400 KB

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 47 ms 1400 KB
in3.txt AC 47 ms 1400 KB
in4.txt AC 47 ms 1400 KB
in5.txt AC 2 ms 256 KB
in6.txt AC 47 ms 1400 KB
in7.txt AC 41 ms 1400 KB
in8.txt AC 47 ms 1400 KB
sample1.txt AC 1 ms 256 KB
sample2.txt AC 1 ms 256 KB