Submission #206117

# Submission time Handle Problem Language Result Execution time Memory
206117 2020-03-02T09:43:43 Z stefdasca Semiexpress (JOI17_semiexpress) C++14
100 / 100
14 ms 504 KB
#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
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 432 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 5 ms 376 KB Output is correct
18 Correct 5 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 432 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 5 ms 376 KB Output is correct
18 Correct 5 ms 504 KB Output is correct
19 Correct 5 ms 376 KB Output is correct
20 Correct 5 ms 376 KB Output is correct
21 Correct 5 ms 380 KB Output is correct
22 Correct 6 ms 380 KB Output is correct
23 Correct 14 ms 424 KB Output is correct
24 Correct 5 ms 376 KB Output is correct
25 Correct 5 ms 376 KB Output is correct
26 Correct 5 ms 376 KB Output is correct
27 Correct 5 ms 376 KB Output is correct
28 Correct 5 ms 376 KB Output is correct
29 Correct 7 ms 376 KB Output is correct
30 Correct 6 ms 376 KB Output is correct