#include<bits/stdc++.h>
using namespace std ;
#define maxn 200009
#define ll long long
#define fi first
#define se second
#define pb push_back
#define left id<<1
#define right id<<1|1
#define _lower(x) lower_bound(v.begin(),v.end(),x)-v.begin()+1
//#define TIME (1.0*clock()/TIME_PERS_SEC)
#define re exit(0);
const int mod = 1e9+7 ;
const int INF = 1e9+1e8 ;
typedef vector<int> vi ;
typedef pair<int,int> pii ;
typedef vector<pii> vii ;
void add ( int &a , int b )
{
a += b ;
if ( a >= mod ) a -= mod ;
if ( a < 0 ) a += mod ;
}
template < typename T > void chkmin ( T &a , T b ) { if ( a > b ) a = b ;}
template < typename T > void chkmax ( T &a , T b ) { if ( a < b ) a = b ;}
void rf ()
{
freopen ("bai1.inp","r",stdin) ;
}
mt19937 rng (time(0)) ;
int _pow ( int a , int n )
{
if ( n == 0 ) return 1 ;
int res = _pow (a,n/2) ;
if ( n % 2 ) return 1ll*res*res%mod*a%mod ;
else return 1ll*res*res%mod ;
}
int n , m , k , A , B , C ;
int express [maxn] , pos_express [maxn] ;
ll TIME ;
int dp [maxn] ;
void sub1 ()
{
int res = 0 ;
for ( int one = 1 ; one <= n ; one ++ ) for ( int two = one+1 ; two <= n ; two ++ )
{
if ( pos_express [one] == 0 && pos_express [two] == 0 )
{
fill (dp+1,dp+n+1,INF) ;
for ( int i = 1 ; i <= n ; i ++ )
{
if ( i == 1 ) dp [i] = 0 ;
else chkmin (dp[i],dp[i-1]+A) ;
if ( pos_express[i] != 0 )
{
if ( pos_express[i] < m )
{
int nxt = express[pos_express[i]+1] ;
chkmin (dp[nxt],dp[i]+(nxt-i)*B) ;
}
if ( one > i )
{
int nxt = one ;
chkmin (dp[nxt],dp[i]+(nxt-i)*C) ;
}
if ( two > i )
{
int nxt = two ;
chkmin (dp[nxt],dp[i]+(nxt-i)*C) ;
}
}
}
int ans = 0 ;
for ( int i = 2 ; i <= n ; i ++ ) if ( dp [i] <= TIME ) ans ++ ;
chkmax(res,ans) ;
}
}
cout << res ; re
}
int main ()
{
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
// rf () ;
cin >> n >> m >> k ;
cin >> A >> B >> C >> TIME ;
for ( int i = 1 ; i <= m ; i ++ )
{
cin >> express [i] ;
pos_express [express[i]] = i ;
}
if ( n <= 300 && k == m+2 ) sub1 () ;
}
Compilation message
semiexpress.cpp: In function 'void rf()':
semiexpress.cpp:33:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
33 | freopen ("bai1.inp","r",stdin) ;
| ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
47 ms |
2396 KB |
Output is correct |
2 |
Correct |
43 ms |
2392 KB |
Output is correct |
3 |
Correct |
21 ms |
2392 KB |
Output is correct |
4 |
Correct |
43 ms |
2396 KB |
Output is correct |
5 |
Correct |
40 ms |
2396 KB |
Output is correct |
6 |
Correct |
41 ms |
2396 KB |
Output is correct |
7 |
Correct |
39 ms |
2496 KB |
Output is correct |
8 |
Correct |
38 ms |
2500 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
47 ms |
2396 KB |
Output is correct |
2 |
Correct |
43 ms |
2392 KB |
Output is correct |
3 |
Correct |
21 ms |
2392 KB |
Output is correct |
4 |
Correct |
43 ms |
2396 KB |
Output is correct |
5 |
Correct |
40 ms |
2396 KB |
Output is correct |
6 |
Correct |
41 ms |
2396 KB |
Output is correct |
7 |
Correct |
39 ms |
2496 KB |
Output is correct |
8 |
Correct |
38 ms |
2500 KB |
Output is correct |
9 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
47 ms |
2396 KB |
Output is correct |
2 |
Correct |
43 ms |
2392 KB |
Output is correct |
3 |
Correct |
21 ms |
2392 KB |
Output is correct |
4 |
Correct |
43 ms |
2396 KB |
Output is correct |
5 |
Correct |
40 ms |
2396 KB |
Output is correct |
6 |
Correct |
41 ms |
2396 KB |
Output is correct |
7 |
Correct |
39 ms |
2496 KB |
Output is correct |
8 |
Correct |
38 ms |
2500 KB |
Output is correct |
9 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |