Submission #1157276
Source Code Expand
#include <cstdio>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <vector>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <chrono>
#include <sstream>
#include <iomanip>
#define INF 1 << 30
#define MOD 1000000007;
#define pi 3.14159265358979
#define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r) for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r) for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define D(x) cout << x << endl
#define d(x) cout << x
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define mp(x, y) make_pair((x), (y))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }
static const int dx[] = {0, 0, 1, -1};
static const int dy[] = {-1, 1, 0, 0};
int main() {
ll n, c, k;
cin >> n >> c >> k;
ll t[101010];
for (int i = 0; i < n; i++) {
cin >> t[i];
}
sort(t, t + n);
ll ans = 0;
bool flag = true;
int limit, cnt;
for (int i = 0; i < n; i++) {
if (flag) {
int ft = t[i];
limit = ft + k;
cnt = 1;
ans++;
flag = false;
} else {
cnt++;
if (cnt > c || t[i] > limit) {
flag = true;
i--;
}
}
}
D(ans);
return 0;
}
Submission Info
Submission Time |
|
Task |
A - Airport Bus |
User |
KokiYmgch |
Language |
C++14 (GCC 5.4.1) |
Score |
300 |
Code Size |
1777 Byte |
Status |
AC |
Exec Time |
47 ms |
Memory |
1024 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
300 / 300 |
Status |
|
|
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 |
46 ms |
1024 KB |
in3.txt |
AC |
46 ms |
1024 KB |
in4.txt |
AC |
47 ms |
1024 KB |
in5.txt |
AC |
2 ms |
256 KB |
in6.txt |
AC |
47 ms |
1024 KB |
in7.txt |
AC |
41 ms |
896 KB |
in8.txt |
AC |
47 ms |
1024 KB |
sample1.txt |
AC |
1 ms |
256 KB |
sample2.txt |
AC |
1 ms |
256 KB |