This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "bits/stdc++.h"
using namespace std;
const int MAXN = 1e5 + 10;
const int MOD = 1e9 + 7;
#define int long long
mt19937_64 rng((int)std::chrono::steady_clock::now().time_since_epoch().count());
int rnd(int x, int y) {
int u = uniform_int_distribution<int>(x, y)(rng); return u;
}
int S[MAXN];
int N, M, K, A, B, C, T;
int dist(int x) {
int lb = 1, rb = M;
while(lb < rb) {
int mid = (lb + rb + 1) >> 1;
if(S[mid] <= x) lb = mid;
else rb = mid - 1;
}
return (S[lb] - 1) * B + (x - S[lb]) * A;
}
void solve(int tc) {
cin >> N >> M >> K >> A >> B >> C >> T;
for(int i=1; i<=M; i++)cin >> S[i];
vector<queue<int> > v;
int ans = 0;
vector<int> st;
for(int i=1; i<M; i++) {
queue<int> r;
for(int j=S[i]+1; j<S[i+1]; j++) {
r.push(j);
}
while(r.size()) {
if(dist(r.front()) <= T) {
ans++; r.pop();
}
else {
break;
}
}
v.push_back(r);
st.push_back(S[i]);
}
for(int i=1; i<=K-M; i++) {
vector<pair<int, int> > w;
for(int j=0; j<v.size(); j++) {
if(v[j].empty()) continue;
int val = v[j].size();
int fidi = dist(v[j].front()) - (v[j].front() - st[j]) * (A - C);
int runs;
if(T < fidi) runs = 0;
else runs = (T - fidi) / A + 1;
val = min(val, runs);
w.push_back({val, j});
}
if(w.empty()) break;
sort(w.begin(), w.end());
reverse(w.begin(), w.end());
int idx = w[0].second;
int ono = v[idx].front();
while(v[idx].size()) {
if(dist(v[idx].front()) - (ono - st[idx]) * (A - C) <= T) {
ans++; v[idx].pop();
}
else {
break;
}
}
}
for(int i=2; i<=M; i++) {
if(dist(S[i]) <= T) ans++;
}
cout << ans << "\n";
}
int32_t main(){
ios::sync_with_stdio(0); cin.tie(0);
int t = 1; //cin >> t;
for(int i=1; i<=t; i++) solve(i);
}
Compilation message (stderr)
semiexpress.cpp: In function 'void solve(long long int)':
semiexpress.cpp:45:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::queue<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
45 | for(int j=0; j<v.size(); j++) {
| ~^~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |