Submission #391168

#TimeUsernameProblemLanguageResultExecution timeMemory
391168paliloTaxis (POI13_tak)C++17
20 / 100
138 ms13508 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; // -----------(d)---------------> m // n texis vector<int64_t> a(n); for (auto& x : a) cin >> x; sort(a.begin(), a.end(), greater<int64_t>()); if (auto it = upper_bound(a.begin(), a.end(), m - d, greater<int64_t>()); it == a.begin()) return cout << 0, 0; else a.erase(prev(it)); 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 >= 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...