Submission #418048

#TimeUsernameProblemLanguageResultExecution timeMemory
418048ChaskaFire (JOI20_ho_t5)C++11
1 / 100
1096 ms5356 KiB
#include <bits/stdc++.h> #define F first #define S second #define ll long long using namespace std; typedef pair<long long,long long> ii; const int N = 2e5+5; ll n,q; ll a[N],b[N]; int main() { cin.tie(0); ios_base::sync_with_stdio(0); cin >> n >> q; for (int i=1;i<=n;i++) cin >> a[i]; while (q--) { int x,l,r; cin >> x >> l >> r; for (int i=1;i<=n;i++) b[i] = 0; for (int i=1;i<=n;i++) for (int j=0;j<=x;j++) { if (i+j<=n) b[i+j] = max(b[i+j],a[i]); } ll s = 0; for (int i=l;i<=r;i++) s += b[i]; cout << s << "\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...