Submission #242344

#TimeUsernameProblemLanguageResultExecution timeMemory
242344SomeoneUnknownTriple Jump (JOI19_jumps)C++14
0 / 100
169 ms40164 KiB
#include <bits/stdc++.h> using namespace std; struct nodei{ int lo, hi, mid, val; int lazyclr; nodei *lft, *rght; nodei(int l, int h){ lo = l; hi = h; mid = (l+h)/2; val = 0; lazyclr = 0; if(h<l) exit(-1); if(l<h){ lft = new nodei(l, mid); rght = new nodei(mid+1, h); } } void propogate(){ //if(!lazyclr) return; //val = 0; if(lo<hi){ lft->lazyclr += lazyclr; rght->lazyclr += lazyclr; } val += lazyclr; lazyclr = 0; } int queryf(){ propogate(); if(lo == hi) return lo; lft->propogate(); rght->propogate(); if(lft->val < rght->val){ return rght->queryf(); }else{ return lft->queryf(); } } int queryr(int l, int h){ propogate(); if(l <= lo && h >= hi) return val; if(l > mid) return rght->queryr(l, h); if(h <= mid) return lft->queryr(l, h); return max(lft->queryr(l, h), rght->queryr(l, h)); } void update(int l, int h, int v){ propogate(); if(l <= lo && h >= hi){ lazyclr += v; return; } if(h > mid) rght->update(l, h, v); if(l <= mid) lft->update(l, h, v); lft->propogate(); rght->propogate(); val = max(lft->val, rght->val); } //write query! } *rootv, *rootc; int main(){ int n; scanf("%d", &n); rootv = new nodei(0, n-1); int firm[n]; for(int i = 0; i < n; ++i){ scanf("%d", &firm[i]); rootv->update(i, i, firm[i]); } int best[n][n]; for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++){ best[i][j] = 0; if(j <= i+1){ continue; } int base = firm[i]+firm[j]; best[i][j] = rootv->queryr(i+1, (i+j)/2); } } int q; scanf("%d", &q); for(int i = 0; i < q; i++){ int a, c; scanf("%d %d", &a, &c); int cbest = 0; for(int j = a; j < c; j++){ for(int k = j+2; k <= c; k++){ cbest = max(cbest, best[j-1][k-1]); } } printf("%d\n", cbest); } }

Compilation message (stderr)

jumps.cpp: In function 'int main()':
jumps.cpp:81:17: warning: unused variable 'base' [-Wunused-variable]
             int base = firm[i]+firm[j];
                 ^~~~
jumps.cpp:67:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
jumps.cpp:71:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &firm[i]);
         ~~~~~^~~~~~~~~~~~~~~~
jumps.cpp:86:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &q);
     ~~~~~^~~~~~~~~~
jumps.cpp:89:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d", &a, &c);
         ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...