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;
}
void solve(int tc) {
int N, M, K;
cin >> N >> M >> K;
int A, B, C;
cin >> A >> B >> C;
int T;
cin >> T;
int S[M+1];
for(int i=1; i<=M; i++)cin >> S[i];
int dist[N+1];
dist[1] = 0;
int cur = 2;
for(int i=2; i<=N; i++) {
if(S[cur] == i) dist[i] = dist[S[cur - 1]] + (i - S[cur - 1]) * B, cur++;
else dist[i] = dist[i-1] + A;
}
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;
w.push_back({dist[v[j].front()] - (v[j].front() - st[j]) * (A - C), j});
}
if(w.empty()) break;
sort(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;
}
}
st[idx] = ono;
}
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:47: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]
47 | 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... |