Submission #1156747
Source Code Expand
// acdart
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <string>
#include <queue>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <cstdlib>
#include <list>
#include <limits.h>
#include <utility>
#include <functional>
#include <deque>
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define X first
#define Y second
#define F first
#define S second
#define MOD9 1000000009ll
#define MOD7 1000000007ll
#define MOD
#define INF 1023456789ll
#define INF16 10000000000000000ll
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define SZ(x) ((int)(x).size())
#define MAXN 10010
#define MAXM
#define ALL(x) ((x).begin()),((x).end())
#define RESET(a,b) memset(a,b, sizeof a)
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define LEN(X) strlen(X)
#define FI(a,b,c) for(int a=b; a<c; a++)
#define FD(a,b,c) for(int a=b; a>c; a--)
using namespace std;
typedef long long ll;
typedef long long LL;
typedef double db;
typedef double D;
typedef long double ld;
typedef long double LD;
/*********default*********/
int a[100010];
int main()
{
int n, c, s = 0;
int k;
scanf("%d%d%d", &n, &c, &k);
for (int i = 0; i < n; i++) {
scanf("%d", &a[i]);
}
sort(a, a + n);
int t = 0, cnt = c;
for (int i = 0; i < n; i++) {
if (a[i] > t || cnt >= c) {
s++;
t = a[i] + k;
cnt = 1;
} else {
cnt++;
}
}
printf("%d\n", s);
}
Submission Info
Submission Time |
|
Task |
A - Airport Bus |
User |
acdart |
Language |
C++14 (GCC 5.4.1) |
Score |
300 |
Code Size |
1604 Byte |
Status |
AC |
Exec Time |
19 ms |
Memory |
640 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:61: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:63:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &a[i]);
^
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 |
18 ms |
640 KB |
in3.txt |
AC |
18 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 |