Submission #1218842

#TimeUsernameProblemLanguageResultExecution timeMemory
1218842viduxHorses (IOI15_horses)C++17
17 / 100
1592 ms20020 KiB
#include "horses.h"

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;

const ll LLINF = 1e18;
const ll MOD = 1e9+7;

const int MAXN = 5e5+1000;
int n;
vl t(MAXN*2);
void build(vl &a) {
	for (int i = 0; i < n; i++) t[i+n] = a[i];
	for (int i = n-1; i > 0; i--) t[i] = t[i*2]*t[i*2+1];
}
void modify(ll i, ll v) {
	for (t[i += n] = v; i > 1; i /= 2) t[i/2] = t[i]*t[i^1];
}
ll query(int l, int r) { // [l, r)
	ll ans = 1;
	for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
		if (l&1) ans = (ans*t[l++])%MOD;
		if (r&1) ans = (ans*t[--r])%MOD;
	}
	return ans;
}

vl x, y;
ll getBest() {
	ll ans = 0;
	ll mult = 1;
	for (int i = 0; i < n; i++) {
		mult = (mult*x[i])%MOD;
		ans = max(ans, (mult*y[i])%MOD);
	}
	//cout << ans << endl;
	return ans;
}

int init(int N, int X[], int Y[]) {
	n = N;
	x = vl(n);
	y = vl(n);
	for (int i = 0; i < n; i++) x[i] = X[i], y[i] = Y[i];
	return getBest();
}

int updateX(int pos, int val) {	
	x[pos] = val;
	return getBest();
}

int updateY(int pos, int val) {
	y[pos] = val;
	return getBest();
}
#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...