# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
541507 | AmirElarbi | Jousting tournament (IOI12_tournament) | C++14 | 1095 ms | 7244 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>
#define vi vector<int>
#define ve vector
#define ll long long
#define vf vector<float>
#define vll vector<pair<ll,ll>>
#define ii pair<int,int>
#define pll pair<ll,ll>
#define vvi vector<vi>
#define vii vector<ii>
#define gii greater<ii>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF 2e9+5
#define eps 1e-7
#define eps1 1e-25
#define optimise ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MAX_A 1e5+5
#define V 450
using namespace std;
const int MOD = 1e9;
const int nax = 1e5+5;
int st[nax][30];
int lg[nax+1];
int GetBestPosition(int n, int c, int r, int *k, int *s, int *e) {
vi rngs(n);
for (int i = 0; i < n; ++i)
rngs[i] = i;
for (int i = 0; i < c; ++i)
{
int lb = lower_bound(rngs.begin(), rngs.end(), s[i])-rngs.begin();
int ub = upper_bound(rngs.begin(), rngs.end(), e[i])-rngs.begin()-1;
for (int j = lb; j <= ub; ++j)
rngs[j] = rngs[lb];
for (int j = ub+1; j < n; ++j)
rngs[j] -= (e[i]-s[i]);
s[i] = lb,e[i] = ub;
}
int mx = 0, ps = 0;
lg[1] = 0;
for (int i = 2; i < nax; i++)
lg[i] = lg[i/2] + 1;
for (int i = 0; i < n-1; i++)
st[i][0] = k[i];
for (int j = 1; j < 30; j++)
for (int i = 0; i + (1 << j) <= n; i++)
st[i][j] = max(st[i][j-1], st[i + (1 << (j - 1))][j - 1]);
for (int i = 0; i < n; ++i)
{
int res = 0, ind = i;
for (int j = 0; j < c; ++j)
{
if(s[j] <= i && i <= e[j]){
int clg = lg[e[j] - s[j] ];
int cur = max(st[s[j]][clg], st[e[j] - (1 << clg)][clg]);
if(cur < r)
res++;
else break;
}
}
if(res > mx){
mx = res;
ps = i;
}
}
return ps;
}
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... |