답안 #1081247

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1081247 2024-08-29T20:22:51 Z Mkswll Semiexpress (JOI17_semiexpress) C++17
100 / 100
18 ms 15964 KB
#include <bits/stdc++.h>
using namespace std;
#define vt vector
#define F first
#define S second
#define pb push_back
#define all(v) v.begin(), v.end()
typedef long long ll;

const int MAXN = 1e5 + 5, MAXM = 3e3 + 5;

int n, m, k;
ll A, B, C;
ll T;

ll s[MAXM];

list <int> rec[MAXN];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> n >> m >> k;
    cin >> A >> B >> C;
    cin >> T;
    for(int i = 1; i <= m; ++i) {
        cin >> s[i];
    }
    k -= m;
    int ans = (n - 1) * B <= T;
    for(int i = 1; i < m && T > 0; ++i, T -= B * (s[i] - s[i - 1])) {
        ll t = T;
        int left = s[i + 1] - s[i];
        ll take = min(t / A, (ll) left - 1) + 1;
        ans += take;
        left -= take;
        int last = s[i], mx = s[i] + take - 1;
        int cnt = k;
        while(left && t > 0 && mx < s[i + 1] - 1 && cnt) {
            t -= C * (mx + 1 - last);
            if(t < 0) break;
            ll take = min(t / A, (ll) left - 1) + 1;
            rec[i].pb(take);
            left -= take;
            last = mx + 1;
            mx += take;
            --cnt;
        }
    }
    priority_queue <pair <int, int> > q;
    for(int i = 1; i < m; ++i) {
        if(!rec[i].empty()) {
            q.push({rec[i].front(), i});
            rec[i].pop_front();
        }
    }
    for(int i = 1; i <= k && !q.empty(); ++i) {
        ans += q.top().F;
        int cur = q.top().S;
        q.pop();
        if(!rec[cur].empty()) {
            q.push({rec[cur].front(), cur});
            rec[cur].pop_front();
        }
    }

    cout << ans - 1 << "\n";

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 2 ms 2648 KB Output is correct
7 Correct 1 ms 2648 KB Output is correct
8 Correct 1 ms 2648 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 2 ms 2648 KB Output is correct
7 Correct 1 ms 2648 KB Output is correct
8 Correct 1 ms 2648 KB Output is correct
9 Correct 1 ms 2648 KB Output is correct
10 Correct 1 ms 2648 KB Output is correct
11 Correct 1 ms 2812 KB Output is correct
12 Correct 1 ms 2812 KB Output is correct
13 Correct 2 ms 2648 KB Output is correct
14 Correct 2 ms 2652 KB Output is correct
15 Correct 1 ms 2652 KB Output is correct
16 Correct 1 ms 2652 KB Output is correct
17 Correct 1 ms 2652 KB Output is correct
18 Correct 1 ms 2812 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 2 ms 2648 KB Output is correct
7 Correct 1 ms 2648 KB Output is correct
8 Correct 1 ms 2648 KB Output is correct
9 Correct 1 ms 2648 KB Output is correct
10 Correct 1 ms 2648 KB Output is correct
11 Correct 1 ms 2812 KB Output is correct
12 Correct 1 ms 2812 KB Output is correct
13 Correct 2 ms 2648 KB Output is correct
14 Correct 2 ms 2652 KB Output is correct
15 Correct 1 ms 2652 KB Output is correct
16 Correct 1 ms 2652 KB Output is correct
17 Correct 1 ms 2652 KB Output is correct
18 Correct 1 ms 2812 KB Output is correct
19 Correct 2 ms 2652 KB Output is correct
20 Correct 2 ms 2652 KB Output is correct
21 Correct 1 ms 2648 KB Output is correct
22 Correct 2 ms 3164 KB Output is correct
23 Correct 18 ms 15964 KB Output is correct
24 Correct 2 ms 2908 KB Output is correct
25 Correct 1 ms 2652 KB Output is correct
26 Correct 2 ms 2652 KB Output is correct
27 Correct 2 ms 2908 KB Output is correct
28 Correct 2 ms 2908 KB Output is correct
29 Correct 11 ms 11612 KB Output is correct
30 Correct 8 ms 8396 KB Output is correct