# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
50263 | gs13105 | Semiexpress (JOI17_semiexpress) | C++17 | 18 ms | 3536 KiB |
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 <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <iterator>
using namespace std;
int arr[3010];
vector<int> mem[3010];
struct str
{
int x, y;
bool operator <(const str &a) const
{
return mem[x][y] < mem[a.x][a.y];
}
};
int main()
{
//freopen("in", "r", stdin);
//freopen("out", "w", stdout);
int n, m, k, a, b, c, i, j;
long long t;
scanf("%d%d%d%d%d%d%lld", &n, &m, &k, &a, &b, &c, &t);
for(i = 0; i < m; i++)
scanf("%d", &arr[i]);
k -= m;
priority_queue<str> pq;
int r = -1;
for(i = 0; i < m - 1; i++)
{
long long t2 = t - 1LL * b * (arr[i] - 1);
int sum = 0;
for(j = 0; t2 >= 0 && j <= k; j++)
{
long long x = 1 + t2 / a;
if(x + sum >= arr[i + 1] - arr[i])
{
mem[i].push_back(arr[i + 1] - arr[i] - sum);
break;
}
mem[i].push_back(x);
sum += x;
t2 -= 1LL * c * x;
}
if(mem[i].size() >= 1)
{
r += mem[i][0];
if(mem[i].size() >= 2)
pq.push({ i, 1 });
}
}
if(1LL * b * (n - 1) <= t)
r++;
for(i = 0; !pq.empty() && i < k; i++)
{
str p = pq.top();
pq.pop();
r += mem[p.x][p.y];
if(p.y + 1 < mem[p.x].size())
pq.push({ p.x, p.y + 1 });
}
printf("%d\n", r);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |