Submission #1157570
Source Code Expand
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n1,n2) for(int (i)=(int)(n1);(i)<(int)(n2);++(i))
#define lpr(i,n1,n2) for(int (i) =(int)(n1); (i) >= (int)(n2);--(i))
#define scan(a) scanf("%d",&a)
#define scan2(a,b) scanf("%d %d",&a,&b);
#define scan3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define PI 3.14159265
#define F first
#define S second
typedef map<int,int> mii;
typedef map<string,string> mss;
typedef map<char,int> mci;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef long long ll;
static const int INF = 0x3f3f3f3f;
static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
int A[1000001];
int main()
{
int n,c,k;
scan3(n,c,k);
int wait = -1,cont = 0,ans = 0;
lp(i,0,n)
scan(A[i]);
sort(A,A+n);
lp(i,0,n)
{
int a;
a = A[i];
if( wait == -1)
wait = a;
//printf("%d\n",wait);
if( a-wait > k)
{
ans++;
wait = a;
cont = 1;
}
else if( cont+1 == c)
{
ans++;
cont = 0;
wait = -1;
}
else
cont++;
}
if( cont > 0)
{
ans++;
}
cout<<ans;
return 0;
}
Submission Info
Submission Time
2017-03-12 21:37:51+0900
Task
A - Airport Bus
User
praveen_4698
Language
C++14 (GCC 5.4.1)
Score
300
Code Size
1536 Byte
Status
AC
Exec Time
19 ms
Memory
640 KB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:27:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scan3(n,c,k);
^
./Main.cpp:30:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scan(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
19 ms
640 KB
in3.txt
AC
19 ms
640 KB
in4.txt
AC
19 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