Submission #391173

#TimeUsernameProblemLanguageResultExecution timeMemory
391173paliloTaxis (POI13_tak)C++17
90 / 100
136 ms4172 KiB
#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 pos = 0; int ans = 0; for (const auto& x : a) { if (x <= d - pos) return cout << (last_taxi < (d - pos) + (m - pos) ? 0 : ans + 1), 0; pos += x - (d - pos); ++ans; if (pos >= d) break; } cout << ans + (pos < m); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...