#include<vector>
#include<algorithm>
#include<set>
#include<iostream>
#include<map>
using namespace std;
set<int> express;
set<int> semiexpress;
int n,m,k,a,b,c,T;
int simulate(int s,int e,int deltaT){
//cout << "s" << s << " e" << e << " " << deltaT << endl;
bool nxt = false;
int dx = e-s;
if( dx*a + deltaT <= T){
return dx*a;
}
else if(find(semiexpress.begin(),semiexpress.end(),s) != semiexpress.end()) {
auto neit = lower_bound(express.begin(),express.end(),e);
while(*neit>e && neit != express.begin()){
neit--;
}
if((neit == express.begin() && *neit > e )|| (*neit < s)|| *neit == s ){
nxt = true;
}
int plus_t=0;
int ne = 0;
if(!nxt){
ne= *neit;
dx = ne-s;
plus_t = simulate(ne,e,dx*b + deltaT);
}
if( !nxt && dx*b + deltaT + plus_t <= T){
return dx*b + plus_t;
}else{
auto neit2 = lower_bound(semiexpress.begin(),semiexpress.end(),e);
while(*neit2>e && neit2 != semiexpress.begin()){
neit2--;
}
if((neit2 == semiexpress.begin() && *neit2 > e )|| (*neit2 < s)|| *neit2 == s ){
// cout << "rip";
return T+1;
}
ne = *neit2;
dx = ne-s;
plus_t = simulate(ne,e,dx*c + deltaT);
if( dx*c + deltaT + plus_t <= T){
return dx*b + plus_t;
}else{
return T+1;
}
}
}else{
return T+1;
}
}
int main(){
cin >> n >> m >> k >>a >> b>>c >> T ;
for(int i = 1;i <= m;i++){
int j;
cin >> j;
express.insert(j);
semiexpress.insert(j);
}
int max_counter=-1;
/*
semiexpress.insert(5);
semiexpress.insert(8);
cout << simulate(1,9,0);*/
for(int a1 = 1;a1 <= n;a1++){
if(express.find(a1) != express.end())
continue;
semiexpress.insert(a1);
for(int a2 = a1+1;a2 <= n;a2++){
if(express.find(a2) != express.end() && a1!= a2)
continue;
semiexpress.insert(a2);
int counter = 0;
for(int i = 2;i <= n;i++){
int t = simulate(1,i,0);
// cout << t << endl;
if(t <=T)
counter++;
}
max_counter = max(max_counter,counter);
semiexpress.erase(a2);
}
semiexpress.erase(a1);
}
cout << max_counter;
}
Compilation message
semiexpress.cpp: In function 'int main()':
semiexpress.cpp:83:13: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
if(express.find(a2) != express.end() && a1!= a2)
^~
semiexpress.cpp:85:17: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
semiexpress.insert(a2);
^~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
49 ms |
256 KB |
Output is correct |
2 |
Execution timed out |
1093 ms |
256 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
49 ms |
256 KB |
Output is correct |
2 |
Execution timed out |
1093 ms |
256 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
49 ms |
256 KB |
Output is correct |
2 |
Execution timed out |
1093 ms |
256 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |