# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
545061 | Asymmetry | Fire (JOI20_ho_t5) | C++17 | 1095 ms | 11752 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//Autor: Bartłomiej Czarkowski
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
template<class A,class B>auto&operator<<(ostream&o,pair<A,B>p){return o<<'('<<p.first<<", "<<p.second<<')';}
template<class T>auto operator<<(ostream&o,T x)->decltype(x.end(),o){o<<'{';int i=0;for(auto e:x)o<<(", ")+2*!i++<<e;return o<<'}';}
#define debug(x...) cerr<<"["#x"]: ",[](auto...$){((cerr<<$<<"; "),...);}(x),cerr<<'\n'
#else
#define debug(...) {}
#endif
struct pytanie {
int l, r, id;
};
const int N = 201000;
int n, q;
int t[N];
long long odp[N];
vector<pytanie> pyt[N]; // zapytania po czasie
int main() {
scanf("%d%d", &n, &q);
for (int i = 1; i <= n; ++i) {
scanf("%d", &t[i]);
}
for (int i = 1; i <= q; ++i) {
int a, b, c;
scanf("%d%d%d", &c, &a, &b);
pyt[c].push_back({a, b, i});
}
for (int i = 1; i <= n; ++i) {
for (int j = n; j; --j) {
t[j] = max(t[j], t[j - 1]);
}
for (auto j : pyt[i]) {
long long ret = 0;
for (int k = j.l; k <= j.r; ++k) {
ret += t[k];
}
odp[j.id] = ret;
}
}
for (int i = 1; i <= q; ++i) {
printf("%lld\n", odp[i]);
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |