이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
#ifdef home
freopen("in", "r", stdin);
freopen("out", "w", stdout);
#endif
int64_t m, d;
int n;
cin >> m >> d >> n;
vector<int64_t> a(n);
for (auto& x : a) cin >> x;
sort(a.begin(), a.end(), greater<int64_t>());
int64_t last_taxi;
if (auto it = upper_bound(a.begin(), a.end(), m - d, greater<int64_t>()); it == a.begin())
return cout << 0, 0;
else {
last_taxi = *prev(it);
a.erase(prev(it));
}
int64_t mid = m - last_taxi;
// mid에 도착하면 한 번에 골인 가능
int64_t pos = 0;
int ans = 0;
for (const auto& x : a) {
if (x <= d - pos) return cout << 0, 0;
pos += x - (d - pos);
++ans;
if (pos >= mid) break;
}
cout << ans + (pos < m);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |