Submission #1092326

# Submission time Handle Problem Language Result Execution time Memory
1092326 2024-09-23T19:19:24 Z PagodePaiva Dungeon 3 (JOI21_ho_t5) C++17
0 / 100
273 ms 672 KB
#include<bits/stdc++.h>
#define int long long

using namespace std;

const int N = 3010;
int a[N], b[N];

int32_t main(){
    int n, m;
    cin >> n >> m;
    for(int i = 1;i <= n;i++){
        cin >> a[i];
    }
    for(int i = 1;i <= n;i++){
        cin >> b[i];
    }
    while(m--){
        int x, y, u;
        cin >> x >> y >> u;
        priority_queue <pair <int, int>> pq;
        bool aux = true;
        int res = 0;
        for(int i = x;i < y;i++){
            if(a[i] > u){
                aux = false;
                break;
            }
            pq.push({-b[i], u});
            int tot = a[i];
            while(!pq.empty()){
                auto [valor, qtd] = pq.top();
                pq.pop();
                valor *= -1;
                if(tot >= qtd){
                    tot -= qtd;
                    res += valor*qtd;
                }
                else{
                    res += valor*tot;
                    pq.push({-valor, qtd-tot});
                    break;
                }
            }
        }
        if(!aux){
            cout << -1 << '\n';
        }
        else{
            cout << res << '\n';
        }
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 273 ms 672 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 273 ms 672 KB Output isn't correct
2 Halted 0 ms 0 KB -