This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, m, k;
ll statii[3002], pozok[3002], timp[3002], prv[3002];
bool bad[3002];
ll a, b, c, t;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> m >> k;
cin >> a >> b >> c;
cin >> t;
for(int i = 1; i <= m; ++i)
cin >> statii[i];
k -= m;
for(int i = 1; i <= m; ++i)
timp[i] = (statii[i] - 1) * b;
statii[m+1] = statii[m] + 1;
for(int i = 1; i <= m; ++i)
{
ll remtimp = t - timp[i];
if(remtimp < 0)
bad[i] = 1;
else
pozok[i] = min(statii[i+1] - 1, statii[i] + remtimp / a);
prv[i] = statii[i];
}
while(k)
{
ll maxgain = 0;
ll wh = 0;
for(int i = 1; i < m; ++i)
{
if(bad[i])
continue;
if(pozok[i] == statii[i+1] - 1)
continue;
ll tg = timp[i] + 1LL * (pozok[i] + 1 - prv[i]) * c;
if(tg > t)
continue;
int newok = min(statii[i+1] - 1, pozok[i] + 1 + (t - tg) / a);
if(newok - pozok[i] > maxgain)
maxgain = newok - pozok[i], wh = i;
/* else
if(maxgain && newok - pozok[i] == maxgain)
{
if(statii[i+1] - newok > statii[wh+1] - (pozok[wh] + maxgain))
wh = i;
}
*/
}
--k;
if(wh == 0)
break;
ll tg = timp[wh] + 1LL * (pozok[wh] + 1 - prv[wh]) * c;
// cout << pozok[wh] << '\n';
prv[wh] = pozok[wh] + 1;
pozok[wh] = min(statii[wh+1] - 1, prv[wh] + (t - tg) / a);
timp[wh] = tg;
}
ll ans = 0;
for(int i = 1; i <= m; ++i)
if(timp[i] <= t)
{
// cout << pozok[i] << " " << statii[i] << '\n';
ans = ans + pozok[i] - statii[i] + 1;
}
cout << ans - 1;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |