#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(0);
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);
//cout << iStation << ' ' << nbAtteint << endl;
maxAtteint += nbAtteint;
tempsRestant -= tempsSemiExpress * nbAtteint;
//cout << tempsRestant << ' ' << posExpress[iStation+1] - posExpress[iStation] - nbAtteint << endl;
if (tempsRestant >= 0)
pq.emplace(tempsRestant, posExpress[iStation+1]-posExpress[iStation] - nbAtteint);
}
for (int iter(0); iter < nbSemi - nbExpress and !pq.empty(); ++iter)
{
auto curSituation = pq.top(); pq.pop();
if (!curSituation.emplacementsRestant) continue;
int nbPris = curSituation.peutPrendre();
maxAtteint += nbPris;
auto nxtSituation = curSituation.prend();
if (nxtSituation.tempsRestant > 0)
pq.push(nxtSituation);
}
if (tempsExpress * nbStations <= tempsMax)
maxAtteint++;
cout << maxAtteint - 1<< endl;
}
# |
결과 |
실행 시간 |
메모리 |
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 |
1 ms |
364 KB |
Output is correct |
7 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
1 ms |
364 KB |
Output is correct |
7 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
1 ms |
364 KB |
Output is correct |
7 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |