Submission #2195732


Source Code Expand

#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <stack>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <functional>
//#include <unordered_set>
#define INF 2147483647
#define MAXN  100005
#define PII pair<int, int>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
PII	v[MAXN];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
#ifdef local_debug
	ifstream inputs("input.txt");
	cin.rdbuf(inputs.rdbuf());
	freopen("input.txt", "r", stdin);
#endif
	int n, c, k, d;
	while (cin >> n >> c >> k) {
		for (int i = 0; i < n; i++)
		{
			cin >> d;
			v[i].first = d;
			v[i].second = d + k;
		}
		sort(v, v + n, [](PII a, PII b) {
			return a.second < b.second;
		});
		int e = v[0].second;
		int t = 0, cnt = 0;
		for (int i = 1; i < n; i++)
		{
			if (e >= v[i].first)
			{
				t++;
				if (t == c)
				{
					t = 0;
					cnt++;
					e = v[i].second;
				}
			}
			else
			{
				cnt++;
				t = 0;
				e = v[i].second;
			}
		}
		cout << cnt + 1 << endl;
	}
	return 0;
}

Submission Info

Submission Time
Task A - Airport Bus
User vjudge5
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1134 Byte
Status AC
Exec Time 19 ms
Memory 1024 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 18 ms 1024 KB
in3.txt AC 18 ms 1024 KB
in4.txt AC 18 ms 1024 KB
in5.txt AC 1 ms 256 KB
in6.txt AC 18 ms 1024 KB
in7.txt AC 16 ms 896 KB
in8.txt AC 19 ms 1024 KB
sample1.txt AC 1 ms 256 KB
sample2.txt AC 1 ms 256 KB