Submission #524002

# Submission time Handle Problem Language Result Execution time Memory
524002 2022-02-08T14:18:02 Z Monarchuwu Semiexpress (JOI17_semiexpress) C++17
100 / 100
9 ms 1996 KB
// nếu đến s[i] thì đến từ s[i-1] để tối ưu
// từ s[i], đi tối đa bằng local
// đặt semi tại local + 1 và tiếp tục đi tối đa bằng local
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;

const int M = 3000 + 3;
int n, m, k;
int a, b, c; // b < c < a
ll t, s[M];

int arr[M * M], cnt_arr;
int main() {
    cin.tie(NULL)->sync_with_stdio(false);
    cin >> n >> m >> k; k -= m;
    cin >> a >> b >> c;
    cin >> t;
    for (int i = 1; i <= m; ++i) cin >> s[i], --s[i];

    int ans(-1);
    for (int i = 1; i < m; ++i) {
        if (s[i] * b > t) break;
        ++ans;

        ll rem = t - s[i] * b;
        int step = min(rem / a, s[i + 1] - s[i] - 1);
        ans += step;
        for (int j = s[i] + step + 1, cnt(0); (j - s[i]) * c <= rem && j < s[i + 1] && cnt < k; ++cnt) {
            step = min((rem - (j - s[i]) * c) / a, s[i + 1] - j - 1);
            arr[++cnt_arr] = step + 1;
            j += step + 1;
        }
    }
    if (s[m] * b <= t) ++ans;

    sort(arr + 1, arr + cnt_arr + 1, greater<int>());
    for (int i = 1; i <= min(cnt_arr, k); ++i) ans += arr[i];
    cout << ans << '\n';
}
/**  /\_/\
 *  (= ._.)
 *  / >0  \>1
**/
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 288 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 288 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 288 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 2 ms 312 KB Output is correct
23 Correct 9 ms 1996 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 6 ms 1356 KB Output is correct
30 Correct 4 ms 972 KB Output is correct