Submission #964641

#TimeUsernameProblemLanguageResultExecution timeMemory
964641efedmrlrSemiexpress (JOI17_semiexpress)C++17
100 / 100
12 ms6212 KiB
// #pragma GCC optimize("O3,Ofast,unroll-loops") // #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #include <bits/stdc++.h> using namespace std; #define int long long int #define MP make_pair #define pb push_back #define REP(i,n) for(int i = 0; (i) < (n); (i)++) #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() void fastio() { ios_base::sync_with_stdio(false); cin.tie(NULL); } const double EPS = 0.00001; const int INF = 1e9+500; const int N = 3e5+5; const int ALPH = 26; const int LGN = 25; constexpr int MOD = 1e9+7; int n,m,K; int A, B, C; int t; vector<int> s; inline void solve() { cin >> n >> m >> K; cin >> A >> B >> C; cin >> t; s.resize(m); REP(i,m) cin >> s[i]; vector<int> semi; int ans = 0; K = K - m; if((n - 1) * B <= t) ans++; for(int i = 0; i<m - 1; i++) { int cost = (s[i] - 1) * B; if(cost > t) break; int ran = s[i] + (t - cost) / A; ran = min(ran, s[i + 1] - 1); ans += ran - s[i] + 1; // cout << "s:" << s[i] << " " << ran << "\n"; // cout << "ans:" << ans << "\n"; int st = s[i]; for(int j = 1; j <= K; j++) { if(ran + 1 >= s[i + 1]) break; ran++; cost = (s[i] - 1) * B + (ran - s[i]) * C; if(cost > t) break; st = ran; ran += (t - cost) / A; ran = min(ran, s[i + 1] - 1); // cout << "st:" << st << " ran:" << ran << "\n"; semi.pb(ran - st + 1); } } sort(rall(semi)); for(int i = 0; i < min((int)semi.size(), K); i++) { ans += semi[i]; } cout << ans - 1 << "\n"; } signed main() { fastio(); int test = 1; //cin>>test; while(test--) { solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...