답안 #685192

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
685192 2023-01-23T16:45:38 Z coffee5427 Semiexpress (JOI17_semiexpress) C++17
18 / 100
1 ms 300 KB
#include <bits/stdc++.h>
#define int long long
#define pii pair<int, int>
#define pb push_back
#define mk make_pair
#define F first
#define S second
#define ALL(x) x.begin(), x.end()

using namespace std;
using PQ = priority_queue<int, vector<int>, greater<int>>;
 
const int INF = 2e18;
const int maxn = 3e5 + 5;
const int M = 1e9 + 7;

int n, m, k;
int Wa, Wb, Wc;
int T, ans;
priority_queue <pii, vector<pii>, greater<>> pq;
map<int, int> mp;

void init () {
    cin >> n >> m >> k;
    k = k - m;
    cin >> Wa >> Wb >> Wc;

    int x;
    cin >> T;
    for (int i = 1; i <= m; i++) {
        cin >> x;
        pq.push ({x, min (Wa, Wb) * (x - 1)});
        mp[x]++;
    }
}

int get (int w) {
    return max (0LL, (T - w) / Wa);
}

void solve () {
    while (pq.size ()) {
        auto [u, w] = pq.top (); pq.pop ();
        //cout << pq.size () << "\n";
        //cout << "u:" << u << ",w:" << w << "\n";
        if (w <= T) ans++; //cout << "u:" << u << ",add:++\n";
        else continue;
        

        if (mp[u] && pq.size ()) {
            auto [nxt, nxtW] = pq.top ();
            pq.pop ();

            nxtW = min ({nxtW, w + min (Wb, Wa) * (nxt - u)});
            pq.push ({nxt, nxtW});
        }

        if (pq.size ()) {
            if (u + get (w) + 1 < pq.top ().F) {
                if (k) {
                    pq.push ({u + get (w) + 1, w + min (Wc, Wa) * (get (w) + 1)});
                    ans += get (w);
                    //cout << "u:" << u << ",add:" << get (w) << "\n";
                    k--;
                }
                else {
                    auto [nxt, nxtW] = pq.top ();
                    pq.pop ();

                    nxtW = min ({nxtW, w + Wc * (nxt - u), w + Wa * (nxt - u)});
                    pq.push ({nxt, nxtW});
                    ans += get (w);
                    //cout << "u:" << u << ",add:" << get (w) << "\n";
                }
            }
            else {
                auto [nxt, nxtW] = pq.top ();
                pq.pop ();

                nxtW = min ({nxtW, w + Wc * (nxt - u), w + Wa * (nxt - u)});
                pq.push ({nxt, nxtW});
                ans += pq.top ().F - u - 1;
                //cout << "u:" << u << ",add:" << pq.top ().F - u - 1 << "\n";
            }
        }
        else ans += min (n - u, get (w)); //cout << "u:" << u << ",add:" << min (n - u, get (w)) << "\n";
    }

    cout << ans - 1<< "\n";
} 
 
signed main() {
    // ios::sync_with_stdio(0);
    // cin.tie(0);
    int t = 1;
    //cin >> t;
    while (t--) {
        init();
        solve();
    }
} 
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 300 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 300 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 300 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 300 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 296 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 300 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Incorrect 1 ms 212 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 300 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 300 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 296 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 300 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Incorrect 1 ms 212 KB Output isn't correct
16 Halted 0 ms 0 KB -