답안 #1102046

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1102046 2024-10-17T10:54:00 Z Pacybwoah Tower (JOI24_tower) C++17
0 / 100
32 ms 10332 KB
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<cassert>
#include<set>
using namespace std;
typedef long long ll;
ll inf = 8e18;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, q;
    cin >> n >> q;
    ll d, a, b;
    cin >> d >> a >> b;
    vector<pair<int, int>> vec;
    for(int i = 0; i < n; i++){
        ll l, r;
        cin >> l >> r;
        vec.emplace_back(l, r);
        assert(r <= 1000000);
    }
    vector<ll> dp(1000001, inf);
    dp[0] = 0;
    for(auto &[l, r]: vec){
        for(int i = l; i <= r; i++) dp[i] = -1;
    }
    for(int i = 1; i <= 1000000; i++){
        if(dp[i] == -1) continue;
        if(dp[i - 1] != -1) dp[i] = dp[i - 1] + a;
        if(i >= d && dp[i - d] != -1) dp[i] = min(dp[i], dp[i - d] + b);
    }
    for(int i = 0; i < q; i++){
        int x;
        cin >> x;
        if(dp[x] == inf || dp[x] == -1) cout << "-1\n";
        else cout << dp[x] << "\n";
    }
}
// g++ -std=c++17 -Wall -Wextra -Wshadow -fsanitize=undefined -fsanitize=address -o run tower.cpp
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 8276 KB Output is correct
2 Incorrect 4 ms 8276 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 8276 KB Output is correct
2 Incorrect 4 ms 8324 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 10332 KB Output is correct
2 Correct 32 ms 10324 KB Output is correct
3 Runtime error 2 ms 596 KB Execution killed with signal 6
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 8276 KB Output is correct
2 Incorrect 4 ms 8276 KB Output isn't correct
3 Halted 0 ms 0 KB -