Submission #1114870

# Submission time Handle Problem Language Result Execution time Memory
1114870 2024-11-19T17:29:22 Z AdamGS Fire (JOI20_ho_t5) C++17
0 / 100
1000 ms 9984 KB
#include <bits/stdc++.h>

using namespace std;

const int MAX=2*1e5+7;

int ogien[MAX];
int odp[MAX];

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n, q, t, l, r;
    cin >> n >> q;

    vector<pair<pair<int, int>, pair<int, int>>> zapytania;

    for (int i=0; i<n; i++){
        cin >> ogien[i+1];
    }

    for (int i=0; i<q; i++){
        cin >> t >> l >> r;
        zapytania.push_back({{t, i}, {l, r}});
    }

    sort(zapytania.begin(), zapytania.end());

    int it = 0;
    for (int i=1; i<=n; i++){
        for(int j=n; j>0; --j) ogien[j] = max(ogien[j-1], ogien[j]);
        while(zapytania[it].first.first==i){
            int suma=0;
            for (int j=zapytania[it].second.first; j<=zapytania[it].second.second; j++) suma += ogien[j];
            odp[zapytania[it].first.second] = suma;
            it++;
        }
    }

    for (int i=0; i<q; i++) cout << odp[i] << "\n";

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Incorrect 1 ms 336 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Execution timed out 1045 ms 9984 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Execution timed out 1052 ms 7360 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1060 ms 9812 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Incorrect 1 ms 336 KB Output isn't correct
3 Halted 0 ms 0 KB -