Submission #912453

# Submission time Handle Problem Language Result Execution time Memory
912453 2024-01-19T13:34:43 Z goodspeed0208 Semiexpress (JOI17_semiexpress) C++14
100 / 100
1 ms 448 KB
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<map>
#include<unordered_map>
#define int long long
using namespace std;

signed main() {
    int n, m, k, t, a, b, c;
    cin >> n >> m >> k >> a >> b >> c >> t;
    vector<int>v(m+1);
    vector<int>next(m);
    vector<int>use(m);
    priority_queue<pair<int, int> >pq;
    
    int ans = -1; k -= m;
    for (int i = 0 ; i < m ; i++) {
        cin >> v[i];
        if (b * (v[i]-1) <= t) ans++;
    }
    //cout << ans << "\n";
    for (int i = 0 ; i < m-1 ; i++) {
        use[i] = b * (v[i]-1);
        int can = min((t - use[i]) / a, v[i+1] - v[i] - 1);
        can = max(can, 0ll);
        //if (can > 0) {
            next[i] = v[i] + can; 
            ans += can;
            //cout << i << " " << can << " " << next[i] << " " << ans << "\n";
        //}
            
        use[i] += c * (can+1);
        if (use[i] > t) continue;
        can = min((t - use[i]) / a + 1, v[i+1] - next[i] - 1);
        if (can <= 0) continue;
        next[i] += can;
        use[i] += c * (can);
       // cout << i << " " << can << "\n";
        pq.push({can, i});
    }
    while ((k--) && !pq.empty()) {
        int i = pq.top().second;
        ans += pq.top().first;
        //cout << i << " " << pq.top().first << " " << next[i] <<" " << ans << "\n";
        pq.pop();
        
        if (use[i] > t) continue;
        int can = min((t - use[i]) / a + 1, v[i+1] - next[i] - 1);
        if (can <= 0) continue;
        next[i] += can;
        use[i] += c * (can);
        pq.push({can, i});
    }
    cout << ans << "\n";
}
/*int main(){
    int N, M, K;
    int64_t A, B, C, T;
    cin >> N >> M >> K >> A >> B >> C >> T;
    vector<int> S(M+1);
    for(int i=0; i<M; i++){
        cin >> S[i];
        S[i]--;
    }
    // 最後の駅も1つのエリアとして扱うと都合が良いので、仮想的に駅を置いておく
    S[M] = N;

    // スタートの駅を数えてしまうのであらかじめ除いておく
    int ans = -1;
    // ここに利得を格納していく
    vector<int> X;
    // 新しく準急を置ける駅数をKとする
    K -= M;
    
    // エリア [ S[i], S[i+1] ) ごとに計算していく
    for(int i=0; i<M; i++){
        int64_t start = S[i], term = S[i+1];
        // S[i]までの所要時間
        int64_t t = B*S[i];
        if(t > T) continue;

        // 準急なしで到達可能な駅数
        int gain = min(term - start, 1 + (T-t)/A);
        ans += gain;
        cout<< gain <<" ";
        start += gain;

        // 準急を置く駅startを進めながら、追加で到達可能になる駅数を順次求める。最大でもK個
        int num = 0;
        while(start < term && num < K){
            t = B*S[i] + C*(start-S[i]);
            if(t > T) break;
            gain = min(term - start, 1 + (T-t)/A);
            X.push_back(gain);
            start += gain;
            num++;
        }
    }

    // 大きい方からK個取る
    sort(X.rbegin(), X.rend());
    int lim = min(int(X.size()), K);
    for(int i=0; i<lim; i++) ans += X[i];

    cout << ans << endl;
    return 0;
}
*/




# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 428 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 428 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 428 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 448 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 344 KB Output is correct