# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
172472 | mhy908 | Semiexpress (JOI17_semiexpress) | C++14 | 2 ms | 376 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>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const LL llinf=9000000000000000000;
const int inf=2000000000;
int m, k;
LL n, a, b, c, t;
LL arr[3010], ans;
vector<LL> vc;
int main()
{
scanf("%lld %d %d", &n, &m, &k);
scanf("%lld %lld %lld %lld", &a, &b, &c, &t);
k-=m;
for(int i=1; i<=m; i++){
scanf("%lld", &arr[i]);
}
arr[m+1]=n+1;
for(int i=1; i<=m; i++){
LL now=arr[i];
for(int j=0; j<=k&&now<arr[i+1]; j++){
if(t<b*(arr[i]-1)+c*(now-arr[i]))break;
LL nex=(t-b*(arr[i]-1)-c*(now-arr[i]))/a+now;
if(j>1){
if(nex<arr[i+1])ans+=nex-now+1, now=nex+1;
else{
ans+=arr[i+1]-now;
break;
}
}
else{
if(nex<arr[i+1])vc.pb(nex-now+1), now=nex+1;
else{
vc.pb(arr[i+1]-now);
break;
}
}
}
}
sort(all(vc), greater<LL>());
for(int i=0; i<vc.size()&&i<k; i++)ans+=vc[i];
printf("%lld", ans-1);
}
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... |