Submission #234185

#TimeUsernameProblemLanguageResultExecution timeMemory
234185jhtanHorses (IOI15_horses)C++14
17 / 100
1564 ms10148 KiB
#include "horses.h"
#include <algorithm>

using namespace std;

const int MOD = 1000000007;

int V[500000];
int XX[500000];
int YY[500000];
int n;

int init(int N, int X[], int Y[]) {
	// For 17 points	
	/*
	int V[N];
	V[0] = X[0];
	for(int i=1; i<N; i++) V[i]	= V[i-1] * X[i];
	int mx = 0;
	for(int i=0; i<N; i++) mx = max(mx, V[i] * Y[i]);
	*/


	n = N;
	for(int i=0; i<N; i++) {
		YY[i] = Y[i];
		XX[i] = X[i];
	}

	V[0] = X[0];
	for(int i=1; i<N; i++) V[i]	= (V[i-1] * X[i]) % MOD;
	int mx = 0;
	for(int i=0; i<N; i++) mx = max(mx, (V[i] * Y[i])) % MOD;

	return mx;
}

int updateX(int pos, int val) {	
	XX[pos] = val;
	for(int i=pos; i<n; i++) V[i]	= (V[i-1] * XX[i]) % MOD;
	int mx = 0;
	for(int i=0; i<n; i++) mx = max(mx, (V[i] * YY[i])) % MOD;
	return mx;
}

int updateY(int pos, int val) {
	YY[pos] = val;
	int mx = 0;
	for(int i=0; i<n; i++) mx = max(mx, (V[i] * YY[i])) % MOD;
	return mx;
}
#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...