# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
372772 | cpp219 | 코알라 (JOI13_koala) | C++14 | 2077 ms | 4460 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.
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fs first
#define sc second
using namespace std;
typedef pair<ll,ll> LL;
const ll N = 1e5 + 9;
const ll inf = 1e18 + 7;
LL a[N];
ll K,M,D,A,n,dp[N];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
#define task "tst"
if (fopen(task".INP","r")){
freopen(task".INP","r",stdin);
//freopen(task".OUT","w",stdout);
}
cin>>K>>M>>D>>A>>n; a[1].fs = K; a[n + 2].fs = M; n += 2;
for (ll i = 2;i < n;i++) cin>>a[i].fs>>a[i].sc;
for (ll i = n - 1;i > 0;i--){
dp[i] = -inf;
for (ll j = i + 1;j <= n;j++){
ll dis = a[j].fs - a[i].fs;
ll kq = dp[j] + a[j].sc - A * ceil((ld)dis/D);
dp[i] = max(dp[i],kq);
}
}
cout<<dp[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... |