| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 217130 | juggernaut | 코알라 (JOI13_koala) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//Just try and the idea will come
#include<bits/stdc++.h>
#define fr first
#define sc second
using namespace std;
typedef long long int ll;
ll k,m,d,a,n,i,dp[100005],j;
pair<ll,ll>p[100005];
int main(){
scanf("%lld%lld%lld%lld%lld",&k,&m,&d,&a,&n);
for(i=2;i<n+2;i++)scanf("%lld%lld",&p[i].fr,&p[i].sc);
p[1]={k,0};
n+=2;
p[n]={m,0};
for(i=2;i<=n;i++){
dp[i]=dp[j]-a*((p[i].fr-p[1].fr+d-1)/d)+p[i].sc;
cnt=1000;
for(j=i-1;j>0&&cnt--;j--,cnt)dp[i]=max(dp[i],dp[j]-a*((p[i].fr-p[j].fr+d-1)/d)+p[i].sc);
}
printf("%lld",dp[n]);
}
