Submission #33324

# Submission time Handle Problem Language Result Execution time Memory
33324 2017-10-23T13:55:58 Z minhtung0404 Semiexpress (JOI17_semiexpress) C++14
100 / 100
0 ms 2212 KB
#include<bits/stdc++.h>
const long long N = 3005;
using namespace std;

typedef pair <long long, long long> ii;
typedef pair <ii, long long> iii;
priority_queue <iii> mq;

long long n, m, k, a, b, c, s[N], ans, T;

long long cal(long long pos, long long pre){
    long long val = T - (s[pre]-1)*b - (pos-s[pre])*c;
    if (val < 0) return 0;
    return 1 + val/a;
}

int main(){
    cin >> n >> m >> k >> a >> b >> c >> T; k-=m;
    for (long long i = 1; i <= m; i++) cin >> s[i];
    if ((n-1)*b > T) ans = -1;
    for (long long i = 1; i <  m; i++){
        long long pos = s[i], pre = i, val = cal(pos, pre);
        if (pos + val > s[pre+1]) val = s[pre+1]-pos;
        ans += val; pos += val; if (pos == s[pre+1]) continue;
        val = cal(pos, pre);
        if (pos + val > s[pre+1]) val = s[pre+1]-pos;
        mq.push(iii(ii(val, pos), pre));
    }
    for (long long i = 1; i <= k && mq.size(); i++){
        iii z = mq.top(); mq.pop();
        long long pos = z.first.second, val = z.first.first, pre = z.second;
        ans += val; pos += val; if (pos == s[pre+1]) continue;
        val = cal(pos, pre);
        if (pos + val > s[pre+1]) val = s[pre+1] - pos;
        mq.push(iii(ii(val, pos), pre));
    }
    cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2040 KB Output is correct
2 Correct 0 ms 2040 KB Output is correct
3 Correct 0 ms 2040 KB Output is correct
4 Correct 0 ms 2040 KB Output is correct
5 Correct 0 ms 2040 KB Output is correct
6 Correct 0 ms 2040 KB Output is correct
7 Correct 0 ms 2040 KB Output is correct
8 Correct 0 ms 2040 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2040 KB Output is correct
2 Correct 0 ms 2040 KB Output is correct
3 Correct 0 ms 2040 KB Output is correct
4 Correct 0 ms 2040 KB Output is correct
5 Correct 0 ms 2040 KB Output is correct
6 Correct 0 ms 2040 KB Output is correct
7 Correct 0 ms 2040 KB Output is correct
8 Correct 0 ms 2040 KB Output is correct
9 Correct 0 ms 2040 KB Output is correct
10 Correct 0 ms 2040 KB Output is correct
11 Correct 0 ms 2040 KB Output is correct
12 Correct 0 ms 2040 KB Output is correct
13 Correct 0 ms 2040 KB Output is correct
14 Correct 0 ms 2040 KB Output is correct
15 Correct 0 ms 2040 KB Output is correct
16 Correct 0 ms 2040 KB Output is correct
17 Correct 0 ms 2040 KB Output is correct
18 Correct 0 ms 2040 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2040 KB Output is correct
2 Correct 0 ms 2040 KB Output is correct
3 Correct 0 ms 2040 KB Output is correct
4 Correct 0 ms 2040 KB Output is correct
5 Correct 0 ms 2040 KB Output is correct
6 Correct 0 ms 2040 KB Output is correct
7 Correct 0 ms 2040 KB Output is correct
8 Correct 0 ms 2040 KB Output is correct
9 Correct 0 ms 2040 KB Output is correct
10 Correct 0 ms 2040 KB Output is correct
11 Correct 0 ms 2040 KB Output is correct
12 Correct 0 ms 2040 KB Output is correct
13 Correct 0 ms 2040 KB Output is correct
14 Correct 0 ms 2040 KB Output is correct
15 Correct 0 ms 2040 KB Output is correct
16 Correct 0 ms 2040 KB Output is correct
17 Correct 0 ms 2040 KB Output is correct
18 Correct 0 ms 2040 KB Output is correct
19 Correct 0 ms 2212 KB Output is correct
20 Correct 0 ms 2212 KB Output is correct
21 Correct 0 ms 2212 KB Output is correct
22 Correct 0 ms 2212 KB Output is correct
23 Correct 0 ms 2212 KB Output is correct
24 Correct 0 ms 2212 KB Output is correct
25 Correct 0 ms 2040 KB Output is correct
26 Correct 0 ms 2040 KB Output is correct
27 Correct 0 ms 2212 KB Output is correct
28 Correct 0 ms 2212 KB Output is correct
29 Correct 0 ms 2040 KB Output is correct
30 Correct 0 ms 2040 KB Output is correct