Submission #1864876
Source Code Expand
#include <bits/stdc++.h>
#define pb push_back
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
const int INFTY=2e9+1;
const int N=110000;
int t[N];
int main() {
int i, n, c, k, ans=0, deadline=INFTY, w=0;
scanf("%d%d%d", &n, &c, &k);
for(i=0; i<n; i++) scanf("%d", &t[i]);
sort(t, t+n);
for(i=0; i<n; i++) {
if(t[i]>deadline || w==c) {
ans++;
w=0;
deadline=INFTY;
}
w++;
deadline=min(deadline, t[i]+k);
}
if(w) ans++;
printf("%d\n", ans);
return 0;
}
Submission Info
Submission Time |
|
Task |
A - Airport Bus |
User |
Ajira |
Language |
C++14 (GCC 5.4.1) |
Score |
300 |
Code Size |
823 Byte |
Status |
AC |
Exec Time |
19 ms |
Memory |
640 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:23:32: 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:24:42: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
for(i=0; i<n; i++) scanf("%d", &t[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 |