제출 #956261

#제출 시각아이디문제언어결과실행 시간메모리
956261serifefedartar새로운 문제 (POI13_tak)C++17
100 / 100
99 ms8696 KiB
#include <bits/stdc++.h> using namespace std; #define fast ios::sync_with_stdio(0);cin.tie(0); typedef long long ll; #define f first #define s second #define LOGN 20 const ll MOD = 998244353; const ll MAXN = 1e5 + 100; #define int long long vector<ll> x; signed main() { fast ll m, d, n; cin >> m >> d >> n; x = vector<ll>(n); for (int i = 0; i < n; i++) cin >> x[i]; sort(x.begin(), x.end()); auto it = lower_bound(x.begin(), x.end(), m - d); if (it == x.end()) { cout << "0\n"; return 0; } int goal = d - (*it - m + d) / 2; x.erase(it); int cnt = 1; int plc = 0; while (x.size()) { int now = x.back(); x.pop_back(); if (now <= d - plc) break; plc += now - d + plc; cnt++; if (plc >= goal) break; } cout << (plc < goal ? 0 : cnt - (plc >= m)) << "\n"; }
#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...