제출 #1110265

#제출 시각아이디문제언어결과실행 시간메모리
1110265vjudge1Tower (JOI24_tower)C++17
5 / 100
68 ms14416 KiB
#include<bits/stdc++.h> #define INF 1e18 #define fi first #define se second #define FOR(i, k, n) for(ll i = k; i <= n; i++) #define FOR1(i, k, n) for(ll i = k; i >= n; i--) #define pb push_back #define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0) #define vi vector<int> #define pii pair<int, int> #define vii vector<pii> #define ll long long #define vll vector<ll> #define pll pair<ll, ll> #define re return 0 #define mii map<int, int> #define input "BESIEGE.inp" #define output "BESIEGE.out" #define rf freopen(input, "r", stdin); freopen(output, "w", stdout) using namespace std; const int maxn = 1e6 + 5; const int mod = 1e9 + 7; const int base = 998244353; void add(int &a, int b) { a += b; if(a >= mod) a -= mod; if(a < 0) a += mod; } ll dp[maxn]; int a[maxn]; ll A, B, D; int main() { fastio; int n, q; cin >> n >> q; cin >> D >> A >> B; FOR(i, 1, n) { int l, r; cin >> l >> r; a[l]++; a[r + 1]--; } FOR(i, 1, 1000000) a[i] += a[i - 1]; FOR(i, 1, 1000000) { if(a[i]) { dp[i] = INF; continue; } dp[i] = INF; dp[i] = min(dp[i], dp[i - 1] + A); if(i >= D) { dp[i] = min(dp[i], dp[i - D] + B); } } while(q--) { int x; cin >> x; if(dp[x] == INF) cout << "-1\n"; else cout << dp[x] << "\n"; } re; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...