Submission #684465

#TimeUsernameProblemLanguageResultExecution timeMemory
684465Ronin13Semiexpress (JOI17_semiexpress)C++14
100 / 100
9 ms340 KiB
#include <bits/stdc++.h> #define ll long long #define ull unsigned ll #define f first #define s second #define pii pair<int,int> #define pll pair<ll,ll> #define pb push_back #define epb emplace_back using namespace std; int main(){ ll n; cin >> n; ll m; cin >> m; ll k; cin >> k; ll a, b, c; cin >> a >> b >> c; ll t; cin >> t; ll s[m + 1]; ll f[m + 1]; ll ans = 0; for(int i = 1; i <= m; i++) cin >> s[i]; for(int i = 1; i <= m; i++){ if(i == m){ continue; } ll x = (s[i] - 1) * b; if(x > t) f[i] = s[i]; else{ ll v = t - x; v /= a; v++; f[i] = s[i] + v; } f[i] = min(f[i], s[i + 1]); ans += f[i] - s[i]; } if(s[m] * b - b <= t) ans++; k -= m; while(k--){ ll mx, mxi = -1; mx = 0; for(int i = 1; i < m; i++){ ll val = s[i] * b - b; val += (f[i] - s[i]) * c; if(val > t) continue; ll u = t - val; ll cnt = u / a; cnt++; cnt = min(cnt, s[i + 1] - f[i]); if(cnt > mx) mx = cnt, mxi = i; } ans += mx; if(mx){ ll val = s[mxi] * b - b; val += (f[mxi] - s[mxi]) * c; ll u = t - val; u /= a; u++; u = min(u, s[mxi + 1] - f[mxi]); f[mxi] += u; } } cout << ans - 1; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...