# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
169506 | combi1k1 | Semiexpress (JOI17_semiexpress) | C++14 | 277 ms | 33348 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define pb emplace_back
#define ll long long
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int n, m, k; cin >> n >> m >> k;
ll A, B, C; cin >> A >> B >> C;
ll T; cin >> T;
vector<int> s(m);
vector<ll> pot;
for(int i = 0 ; i < m ; ++i) cin >> s[i]; s.pb(n + 1);
for(int i = 0 ; i < m ; ++i) {
ll rem = T - B * (s[i] - 1);
int rig = s[i];
if (rem < 0) {
pot.pb(n);
continue;
}
int Q = 1;
for(int j = 0 ; j < k ; ++j) {
ll nxt = rig + rem / A + 1;
if (nxt > s[i + 1])
nxt = s[i + 1];
ll len = nxt - rig;
pot.pb(len + Q * n); Q = 0;
rig += len;
rem -= len * C;
if (rem < 0) break;
if (rig == s[i + 1]) break;
}
}
sort(pot.begin(),pot.end(),greater<ll>());
if (k > sz(pot))
k = sz(pot);
cout << accumulate(pot.begin(),pot.begin() + k,0ll) - 1ll * m * n - 1 << endl;
}
/*
300 8 16
345678901 123456789 234567890
12345678901
1
10
77
82
137
210
297
300
*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |