# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
597062 | ThegeekKnight16 | Floppy (RMI20_floppy) | C++14 | 0 ms | 0 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.
#include <bits/stdc++.h>
//#include <floppy.h>
using namespace std;
const int MAXN = 4e4 + 10;
vector<int> v(MAXN);
struct node
{
int maxVal, maxId;
node(int Val = -1, int Id = 0) {maxVal = Val; maxId = Id;}
node operator+(node outro)
{
node resp;
resp.maxVal = max(maxVal, outro.maxVal);
resp.maxId = (maxVal >= outro.maxVal) ? maxId : outro.maxId;
return resp;
}
};
node seg[4*MAXN];
void build(int pos, int ini, int fim)
{
if (ini == fim) {seg[pos].maxVal = v[ini]; seg[pos].maxId = ini; return;}
int m = (ini + fim) / 2;
int e = 2*pos; int d = 2*pos + 1;
build(e, ini, m );
build(d, m+1, fim);
seg[pos] = seg[e] + seg[d];
}