# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
29399 | cdemirer | Semiexpress (JOI17_semiexpress) | C++14 | 0 ms | 2224 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 <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> llp;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vii;
typedef vector<vector<pair<int, int> > > vvii;
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)
ll N, M, K;
ll A, B, C;
ll T;
ll S[3000];
ll ans = 0;
ll ng;
ll gsz[3000];
ll gbudget[3000];
set<llp> SS;
void update(int x) {
ll slowrlim = gbudget[x] / A;
if (slowrlim +1> gsz[x]) {
ans += gsz[x];
return;
}
ans += slowrlim + 1;
ll ptr = slowrlim + 1;
if (ptr >= gsz[x]) return;
if (gbudget[x] - ptr*C < 0) {
return;
}
ll semirlim = (gbudget[x]-ptr*C) / A;
if (ptr + semirlim +1 > gsz[x]) semirlim = gsz[x]-ptr-1;
SS.insert(mp(semirlim+1, x));
}
void advance(int x) {
ll ptr = gbudget[x] / A + 1;
gsz[x] -= ptr;
//cerr << "Semi added to group " << x << endl;
gbudget[x] -= ptr*C;
update(x);
}
int main(int argc, char **argv) {
//freopen("input", "r", stdin);
//freopen("output", "w", stdout);
scanf("%lld%lld%lld", &N, &M, &K);
scanf("%lld%lld%lld", &A, &B, &C);
scanf("%lld", &T);
for (int i = 0; i < M; i++) {
scanf("%lld", &(S[i]));
}
ng = M-1;
for (int i = 0; i < ng; i++) {
gsz[i] = S[i+1]-S[i];
gbudget[i] = T - (S[i]-1)*B;
if (gbudget[i] < 0) {
ng = i;
break;
}
}
for (int i = 0; i < ng; i++) {
update(i);
}
K -= M;
while (K-- && SS.size() > 0) {
set<llp>::iterator it = SS.end(); it--;
llp x = *it;
SS.erase(it);
advance(x.second);
}
ans -= 1;
if (T - (S[M-1]-1) * B >= 0) ans += 1;
printf("%lld\n", ans);
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... |