Submission #650329

#TimeUsernameProblemLanguageResultExecution timeMemory
650329600MihneaFire (JOI20_ho_t5)C++17
0 / 100
1059 ms14188 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; struct Op { int limit; int k; int id; }; int main() { #ifndef ONPC ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #endif int n, q; cin >> n >> q; vector<ll> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } // l, r, t vector<ll> prn(2 * q, 0); vector<Op> ops; for (int i = 0; i < q; i++) { int l, r, t; cin >> t >> l >> r; l--, r--; ops.push_back({l - 1, t, i}); ops.push_back({r, t, i + q}); } for (auto &it : ops) { int limit = it.limit; if (limit < 0) { cout << "skip\n"; continue; } int k = it.k; int id = it.id; ll sol = 0; for (int i = 0; i <= limit; i++) { ll mx = a[i]; for (int j = i; j >= i - k + 1 && j >= 0; j--) { mx = max(mx, a[j]); } sol += mx; } prn[id] = sol; } for (int i = 0; i < q; i++) { cout << prn[i + q] - prn[i] << "\n"; } cout << "\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...