Submission #1870436
Source Code Expand
#include <bits/stdc++.h> #define rank tipa_rank #define pb push_back #define mp make_pair #define ll long long #define ull unsigned long long #define INF 1000000000 #define EPS 1e-6 #define EPS2 1e-8 using namespace std; const ll MOD = INF + 7; using namespace std; int n , c , k; int t[100000]; int begT = -1; int cnt = 0; 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++) { if(begT == -1 || t[i] - begT <= k && cnt < c) { if(begT == -1) begT = t[i]; cnt++; } else { ans++; begT = t[i]; cnt = 1; } } ans++; cout << ans; }
Submission Info
Submission Time | |
---|---|
Task | A - Airport Bus |
User | vjudge2 |
Language | C++14 (GCC 5.4.1) |
Score | 300 |
Code Size | 667 Byte |
Status | AC |
Exec Time | 19 ms |
Memory | 640 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:19:34: 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:21:22: 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 |
|
|
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 |