Submission #1157571
Source Code Expand
#include <iostream> #include <algorithm> using namespace std; int check(int N, int C, int K, int* T) { int bus_cnt = 0; int buf = 0; int pos = 0; sort(T, T + N); for (int i = 0; i < N; ++i) { if (buf == 0) { pos = i; } ++buf; if (buf == C) { ++bus_cnt; buf = 0; continue; } if (i == N - 1) { ++bus_cnt; break; } if ((T[i + 1] >= T[pos] + K)) { ++bus_cnt; buf = 0; } } return bus_cnt; } int main(void) { int N, C, K; cin >> N >> C >> K; int* T = new int[N]; for (int i = 0; i < N; ++i) { cin >> T[i]; } int ans = check(N, C, K, T); cout << ans << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - Airport Bus |
User | cosmos0906 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 682 Byte |
Status | WA |
Exec Time | 61 ms |
Memory | 640 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 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 | 256 KB |
in2.txt | AC | 59 ms | 640 KB |
in3.txt | WA | 61 ms | 640 KB |
in4.txt | AC | 59 ms | 640 KB |
in5.txt | AC | 2 ms | 256 KB |
in6.txt | AC | 60 ms | 640 KB |
in7.txt | AC | 52 ms | 640 KB |
in8.txt | AC | 60 ms | 640 KB |
sample1.txt | AC | 1 ms | 256 KB |
sample2.txt | AC | 1 ms | 256 KB |