Submission #1343888

#TimeUsernameProblemLanguageResultExecution timeMemory
1343888madamadam3말 (IOI15_horses)C++20
17 / 100
1595 ms8252 KiB
#include "horses.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vl = vector<int>;
using vvi = vector<vi>;

const ll MOD = 1e9+7;
const ll INF = 4e18;

#define bg(x) (x).begin()
#define en(x) (x).end()
#define all(x) (x).begin(), (x).end()
#define sz(x) (int((x).size()))
#define f first
#define s second
#define pb push_back
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define rev(i, a, b) for (int i = a; i >= b; i--)

template<class T> bool chmax(T& a, const T& b) {return a < b ? a = b, 1 : 0;}
template<class T> bool chmin(T& a, const T& b) {return b < a ? a = b, 1 : 0;}

#ifdef LOCAL
	#define dbg(x) cerr << #x << " = " << x << "\n"
#else
	#define dbg(x)
#endif

int n;
vl x, y;

int compute() {
	ll ans = x[n-1] * y[n-1];
	bool didmod = ans >= MOD; if (didmod) ans %= MOD;
	rev(i, n-2, 0) {
		if (!didmod && y[i] > ans) ans = y[i];
		ans *= x[i];
		didmod = ans >= MOD; if (didmod) ans %= MOD;
	}
	return ans % MOD;
}

int init(int N, int X[], int Y[]) {
	n = N; x.assign(X, X+N); y.assign(Y, Y+N);
	return compute();
}

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

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