Submission #545061

#TimeUsernameProblemLanguageResultExecution timeMemory
545061AsymmetryFire (JOI20_ho_t5)C++17
1 / 100
1095 ms11752 KiB
//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)

ho_t5.cpp: In function 'int main()':
ho_t5.cpp:23:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |  scanf("%d%d", &n, &q);
      |  ~~~~~^~~~~~~~~~~~~~~~
ho_t5.cpp:25:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |   scanf("%d", &t[i]);
      |   ~~~~~^~~~~~~~~~~~~
ho_t5.cpp:29:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |   scanf("%d%d%d", &c, &a, &b);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~
#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...