Submission #1156788
Source Code Expand
#include <iostream> #include <string> #include <algorithm> #include <cstdio> using namespace std; int main() { long long int n,c,k; long long int t[100000] = {0}; scanf("%lld %lld %lld", &n,&c,&k); for(int i = 0; i < n; i++) { scanf("%lld", &t[i]); } sort(t,t+n); long long int bus = 1; int pass = 1; int first = 0; for(int i = 1; i < n; i++) { if (pass < c && t[i] <= t[first] + k) { pass++; }else { bus++; pass = 1; first = i; } } printf("%lld\n", bus); return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - Airport Bus |
User | ykmaku |
Language | C++14 (GCC 5.4.1) |
Score | 300 |
Code Size | 559 Byte |
Status | AC |
Exec Time | 19 ms |
Memory | 1024 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:13:35: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%lld %lld %lld", &n,&c,&k); ^ ./Main.cpp:17:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%lld", &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 | 2 ms | 1024 KB |
in2.txt | AC | 19 ms | 1024 KB |
in3.txt | AC | 19 ms | 1024 KB |
in4.txt | AC | 19 ms | 1024 KB |
in5.txt | AC | 2 ms | 1024 KB |
in6.txt | AC | 19 ms | 1024 KB |
in7.txt | AC | 17 ms | 1024 KB |
in8.txt | AC | 19 ms | 1024 KB |
sample1.txt | AC | 2 ms | 1024 KB |
sample2.txt | AC | 2 ms | 1024 KB |