#include <bits/stdc++.h>
#define int long long
using namespace std;
int nbStations, nbExpress, nbSemi;
int tempsLocal, tempsExpress, tempsSemiExpress, tempsMax;
struct Situation
{
int tempsRestant, emplacementsRestant;
Situation(int a, int b) : tempsRestant(a), emplacementsRestant(b) {}
int peutPrendre(void) const
{
return min(emplacementsRestant, 1 + tempsRestant / tempsLocal);
}
Situation prend(void) const
{
int nbPris = peutPrendre();
return {tempsRestant - tempsSemiExpress * nbPris, emplacementsRestant - nbPris};
}
bool operator<(Situation other) const
{
return peutPrendre() < other.peutPrendre();
}
};
signed main(void)
{
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
cin >> nbStations >> nbExpress >> nbSemi;
cin >> tempsLocal >> tempsExpress >> tempsSemiExpress >> tempsMax;
vector<int> posExpress(nbExpress);
for (auto &v : posExpress)
cin >> v;
priority_queue<Situation> pq;
int maxAtteint(-1);
for (int iStation = 0; iStation < nbExpress-1; ++iStation)
{
int tempsRestant = tempsMax - (posExpress[iStation] - 1) * tempsExpress;
if (tempsRestant < 0) continue;
int nbAtteint = min(posExpress[iStation+1] - posExpress[iStation],
1 + tempsRestant / tempsLocal);
maxAtteint += nbAtteint;
tempsRestant -= tempsSemiExpress * nbAtteint;
if (tempsRestant >= 0)
pq.emplace(tempsRestant, posExpress[iStation+1]-posExpress[iStation] - nbAtteint);
}
if (tempsExpress * (nbStations - 1)<= tempsMax)
maxAtteint++;
for (int iter(0); iter < nbSemi - nbExpress and !pq.empty(); ++iter)
{
auto curSituation = pq.top(); pq.pop();
int nbPris = curSituation.peutPrendre();
maxAtteint += nbPris;
auto nxtSituation = curSituation.prend();
if (nxtSituation.tempsRestant >= 0)
pq.push(nxtSituation);
}
cout << maxAtteint << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
0 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
0 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
1 ms |
492 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
0 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
1 ms |
492 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
19 |
Correct |
1 ms |
364 KB |
Output is correct |
20 |
Correct |
1 ms |
364 KB |
Output is correct |
21 |
Correct |
1 ms |
380 KB |
Output is correct |
22 |
Correct |
1 ms |
364 KB |
Output is correct |
23 |
Correct |
1 ms |
492 KB |
Output is correct |
24 |
Correct |
1 ms |
364 KB |
Output is correct |
25 |
Correct |
1 ms |
364 KB |
Output is correct |
26 |
Correct |
1 ms |
492 KB |
Output is correct |
27 |
Correct |
1 ms |
364 KB |
Output is correct |
28 |
Correct |
1 ms |
364 KB |
Output is correct |
29 |
Correct |
1 ms |
364 KB |
Output is correct |
30 |
Correct |
1 ms |
364 KB |
Output is correct |