Submission #1247223

#TimeUsernameProblemLanguageResultExecution timeMemory
1247223SpyrosAlivHorses (IOI15_horses)C++20
34 / 100
1595 ms8392 KiB
#include "horses.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long

const ll MOD = 1e9+7;
const ll MAXV = 1e9;
const int MN = 5e5+5;
int n;
vector<int> x, y;

int get_ans() {
	ll dp = y[n-1];
	int idx = n-1;
	for (int i = n-2; i >= 0; i--) {
		ll dp2 = max((ll)y[i], (ll)x[i + 1] * dp);
		if (dp2 > MAXV) break;
		dp = dp2;
		idx = i;
	}
	ll b4 = 1;
	for (int i = 0; i <= idx; i++) {
		b4 *= x[i];
		b4 %= MOD;
	}
	dp %= MOD;
	return (b4 * dp) % MOD;
}

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

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

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