#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;
while(v[idx].size()) {
if(dist[v[idx].front()] - (v[idx].front() - 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
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++) {
| ~^~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Incorrect |
0 ms |
332 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Incorrect |
0 ms |
332 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Incorrect |
0 ms |
332 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |