Submission #1114911

#TimeUsernameProblemLanguageResultExecution timeMemory
1114911AdamGSFire (JOI20_ho_t5)C++17
1 / 100
1050 ms18364 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int MAX=2*1e5+7; ll ogien[MAX]; ll odp[MAX]; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); ll n, q, t, l, r; cin >> n >> q; vector<pair<pair<ll, ll>, pair<ll, ll>>> 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()); ll 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){ ll 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...