Submission #854661

#TimeUsernameProblemLanguageResultExecution timeMemory
854661BrineTwSemiexpress (JOI17_semiexpress)C++14
18 / 100
0 ms348 KiB
#pragma GCC optimize("O3") #include <bits/stdc++.h> #define debug(x) cerr << #x << ' ' << x << '\n' #define endl '\n' using namespace std; const int M = 1e9 + 7; typedef long long ll; typedef __int128_t lll; typedef pair<lll, lll> pii; typedef pair<lll, pii> piii; int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); ll N, M, K; cin >> N >> M >> K; K -= M; ll A, B, C; cin >> A >> B >> C; lll vA = A, vB = B, vC = C; ll limit; cin >> limit; vector<lll> exprs; ll t; for (int i = 0; i < M; i++) cin >> t, exprs.push_back(--t); priority_queue<piii, vector<piii>, less<piii>> pq; lll ans = -1; for (int i = 0; i < M - 1; i++) { lll tNow = limit - vB * exprs[i]; if (tNow < 0) break; ans++; lll nxtA = min(tNow / vA + exprs[i], exprs[i + 1] - 1); ans += nxtA - exprs[i]; lll xC = (tNow - (nxtA + 1 - exprs[i]) * vC < 0 ? nxtA : nxtA + 1); lll tC = tNow - (xC - exprs[i]) * vC; lll possible = min(xC + tC / vA, exprs[i + 1] - 1); if (possible - nxtA <= 0) continue; pq.push({possible - nxtA, make_pair(xC, tC)}); } while (pq.size() && K) { auto [dx, xt] = pq.top(); auto& [x, t] = xt; pq.pop(); K--; ans += dx; lll nxtExp = *upper_bound(exprs.begin(), exprs.end(), x); lll nxtA = x + t / vA; lll xC = (t - (nxtA - x + 1) * vC < 0 ? nxtA : nxtA + 1); lll tC = t - (xC - x) * vC; lll possible = min(xC + tC / vA, nxtExp - 1); if (possible - nxtA == 0) continue; pq.push({possible - nxtA, make_pair(xC, tC)}); } if (vB * exprs.back() <= limit) ans++; cout << ll(ans) << '\n'; return 0; }

Compilation message (stderr)

semiexpress.cpp: In function 'int main()':
semiexpress.cpp:54:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   54 |         auto [dx, xt] = pq.top();
      |              ^
semiexpress.cpp:55:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   55 |         auto& [x, t] = xt;
      |               ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...