# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
173454 | dennisstar | Semiexpress (JOI17_semiexpress) | C++11 | 2 ms | 424 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 fi first
#define se second
#define ryan bear
#define all(V) ((V).begin()), ((V).end())
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
typedef vector<int> vim;
typedef vector<ll> vlm;
ll N, M, K, Loc, Ex, Sem, T;
ll S[3010], ans;
priority_queue<pair<ll, pll> > pq;
int main() {
scanf("%lld %lld %lld %lld %lld %lld %lld", &N, &M, &K, &Loc, &Ex, &Sem, &T);
for (int i=1; i<=M; i++) scanf("%lld", &S[i]);
S[M+1]=N+1;
K-=M;
ll LT;
for (int i=1; i<=M; i++) {
if ((S[i]-1)*Ex<=T) {
LT=T-(S[i]-1)*Ex;
ans+=min(S[i+1]-1, S[i]+LT/Loc)-S[i]+1;
if (S[i]+LT/Loc < S[i+1]-1 && (LT-Sem*(LT/Loc+1))>=0 ) { //추가개수, 최대개수, 잔여시간
//시작점 : S[i]+(LT/loc)+1
pq.push({ min(S[i+1]-1-(S[i]+LT/Loc), 1+(LT-Sem*(LT/Loc+1))/Loc) , make_pair(S[i+1]-1-(S[i]+LT/Loc), (LT-Sem*(LT/Loc+1))) });
}
}
}
while (K--&&!pq.empty()) {
auto pi=pq.top(); pq.pop();
ans+=pi.fi;
if (pi.se.fi>pi.fi && pi.se.se>=(Sem+1)*pi.fi) pq.push({ min((pi.se.se-Sem*(pi.fi+1))/Loc+1, pi.se.fi-pi.fi) , make_pair(pi.se.fi-pi.fi, pi.se.se-(Sem+1)*pi.fi) });
}
printf("%lld\n", ans-1);
return 0;
}
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... |