# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1030770 | Antekb | Tower (JOI24_tower) | C++17 | 68 ms | 16732 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" /** keep-include */
using namespace std;
#define rep(i, b, e) for(int i = (b); i <= (e); i++)
#define per(i, b, e) for(int i = (e); i >= (b); i--)
#define FOR(i, b, e) rep(i, b, (e) - 1)
#define SZ(x) int(x.size())
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define st first
#define nd second
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
auto &operator<<(auto &o, pair<auto, auto> p) {
return o << "(" << p.st << ", " << p.nd << ")"; }
auto operator<<(auto &o, auto x)->decltype(end(x), o) {
o << "{"; int i=0; for(auto e: x) o << ", " + 2*!i++ << e;
return o << "}"; }
#ifdef LOCAL
#define deb(x...) cerr << "[" #x "]: ", [](auto...$) { \
((cerr << $ << "; "),...) << endl; }(x)
#else
#define deb(...)
#endif
void solve() {
int n, q;
cin>>n>>q;
ll A, B, D;
cin>>D>>A>>B;
int dl=1e6+5;
vector<bool> blo(dl);
vector<ll> odl(dl, 1e18);
for(int i=0; i<n; i++){
ll l, r;
cin>>l>>r;
for(int j=l; j<=r; j++){
blo[j]=1;
}
}
odl[0]=0;
for(int i=1; i<dl; i++){
if(!blo[i]){
odl[i]=min(odl[i], odl[i-1]+A);
if(i>=D)odl[i]=min(odl[i], odl[i-D]+B);
}
}
while(q--){
ll x;
cin>>x;
if(odl[x]!=1e18)cout<<odl[x]<<"\n";
else cout<<"-1\n";
}
}
int main() {
cin.tie(0)->sync_with_stdio(0);
int tt = 1;
// cin >> tt;
FOR(te, 0, tt) solve();
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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |