Submission #912453

#TimeUsernameProblemLanguageResultExecution timeMemory
912453goodspeed0208Semiexpress (JOI17_semiexpress)C++14
100 / 100
1 ms448 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...