Submission #647969

#TimeUsernameProblemLanguageResultExecution timeMemory
647969Koful123Semiexpress (JOI17_semiexpress)C++17
100 / 100
52 ms17088 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define double long double #define endl "\n" #define pb push_back #define ff first #define ss second #define mod 1000000007 #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() const int N = 3e3 + 3; int dp[N][N]; void solve(){ int n,m,k,a,b,c,t; cin >> n >> m >> k >> a >> b >> c >> t; vector<int> v(m+1); for(int i=1;i<=m;i++){ cin >> v[i]; } for(int i=1;i<m;i++){ int time = t - (v[i]-1)*b,last = 0; vector<int> val(k-m+5,0); for(int q=0;q<=k-m;q++){ if(time - last*c < 0 || last >= v[i+1]) break; int cur = (time - last*c) / a,len = v[i+1] - v[i]; val[q] = min(len,last + cur + 1); last += cur+1; } for(int j=0;j<=k-m;j++){ int l = 0,r = j; while(l < r){ int mm = (l+r+1)/2; int cur = (mm ? val[mm-1] + dp[i-1][j-mm+1] : 0); if(val[mm] + dp[i-1][j-mm] > cur) l = mm; else r = mm-1; } dp[i][j] = val[l] + dp[i-1][j-l]; } } int ans = 0; for(int i=1;i<m;i++){ ans = max(ans,dp[i][k-m]); } cout << ans - ((v[m]-1)*b > t) << endl; } signed main(){ ios::sync_with_stdio(0); cin.tie(0); int t = 1; // cin >> t; while(t--) solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...