Submission #1156432


Source Code Expand

#include<bits/stdc++.h>
#include <regex>
#include<ext/numeric>
#include<ext/hash_map>
using namespace std;
using namespace __gnu_cxx;

#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v)  (int)v.size()
#define WHITE -1
#define GREY   0
#define BLACK  1
#define CLR(a,v) memset(a,v,sizeof a)
#define PC(x) __builtin_popcount(x)
#define MP make_pair

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
//typedef unsigned int ui;

typedef complex<double> point;
//#define X real()
#define Y imag()
#define vec(a,b) ((b)-(a))
#define dot(a,b) ((conj(a)*(b)).real())
#define cross(a,b) ((conj(a)*(b)).imag())
#define colliner pointOnLine
#define same(a,b) (lengthSqr(vec(a,b))<EPS)
#define lengthSqr(v) (dot(v,v))

const double PI = acos(-1.0);

int dx[] = { 0, -1, 0, 1, -1, -1, 1, 1 };
int dy[] = { 1, 0, -1, 0, 1, -1, 1, -1 };

int DX[] = { 1, 1, -1, -1, 2, 2, -2, -2 };
int DY[] = { 2, -2, 2, -2, 1, -1, 1, -1 };

const int MAX = 1e5 + 5, MOD = 1e9 + 7, oo = (1 << 30);
const ll OO = 1ll << 60, MAXN = 1e15;
const double EPS = 1e-9;

int n, c, k, t[MAX];

int main() {

	scanf("%d%d%d", &n, &c, &k);
	for (int i = 0; i < n; ++i)
		scanf("%d", &t[i]);
	sort(t, t + n);
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		int j = i + 1;
		for (; j < n && t[j] - t[i] <= k && j - i + 1 <= c; ++j)
			;
		++ans, i = j - 1;
	}
	printf("%d\n", ans);
}

Submission Info

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

Compile Error

In file included from /usr/include/c++/5/ext/hash_map:60:0,
                 from ./Main.cpp:4:
/usr/include/c++/5/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header which may be removed without further notice at a future date. Please use a non-deprecated interface with equivalent functionality instead. For a listing of replacement headers and interfaces, consult the file backward_warning.h. To disable this warning use -Wno-deprecated. [-Wcpp]
 #warning \
  ^
./Main.cpp: In function ‘int main()’:
./Main.cpp:52:29: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d", &n, &c, &k);
                             ^
./Main.cpp:54:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &t[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