Submission #754761

#TimeUsernameProblemLanguageResultExecution timeMemory
754761PringFire (JOI20_ho_t5)C++14
0 / 100
1 ms340 KiB
#include <bits/stdc++.h> using namespace std; #define int long long typedef pair<int, int> pii; const int MXN = 20; int n, q, a[MXN], ans[MXN]; vector<pair<pii, int>> v[MXN]; int32_t main() { cin >> n >> q; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < q; i++) { int t, l, r; cin >> t >> l >> r; v[t].push_back({{l, r}, i}); } for (int i = 1; i <= n; i++) { for (int j = n - 1; j > 0; j--) a[j] = max(a[j], a[j - 1]); for (auto &j : v[i]) { for (int k = j.first.first; k <= j.first.second; k++) ans[j.second] += a[k - 1]; } } for (int i = 0; i < q; i++) cout << ans[i] << endl; 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...