제출 #1038136

#제출 시각아이디문제언어결과실행 시간메모리
1038136UnforgettableplTower (JOI24_tower)C++17
5 / 100
64 ms16468 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int INF = 1e18+1; int32_t main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int n,q,d,A,B; cin >> n >> q >> d >> A >> B; vector<int> DP(1e6+1); for(int i=1;i<=n;i++){ int l,r;cin>>l>>r; for(int j=l;j<=r;j++)DP[j]=INF; } for(int i=1;i<=1e6;i++){ if(i<d)DP[i]=max(DP[i],DP[i-1]+A); else DP[i]=max(DP[i],min(DP[i-1]+A,DP[i-d]+B)); } for(int i=1;i<=q;i++){ int x;cin>>x; cout << (DP[x]>=INF ? -1 : DP[x]) << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...