Submission #719344

#TimeUsernameProblemLanguageResultExecution timeMemory
719344thimote75Horses (IOI15_horses)C++14
17 / 100
1562 ms14344 KiB
#include "horses.h"

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

const double LMOD = log(1e9 + 7);

int mod_exp (double doub) {
	doub = fmod(doub, LMOD);

	return (int) round(exp(doub));
}

vector<double> lX;
vector<double> lY;

int compute () {
	double max_v = 0;
	double sum_v = 0;

	for (int j = 0; j < lX.size(); j ++) {
		sum_v += lX[j];

		max_v = max(max_v, sum_v + lY[j]);
	}
	
	return mod_exp(max_v);
}

int init(int N, int X[], int Y[]) {
	lX.resize(N);
	lY.resize(N);

	for (int i = 0; i < N; i ++) {
		lX[i] = log((double) X[i]);
		lY[i] = log((double) Y[i]);
	}

	return compute();
}

int updateX(int pos, int val) {
	lX[pos] = log((double) val);
	return compute();
}

int updateY(int pos, int val) {
	lY[pos] = log((double) val);
	return compute();
}

Compilation message (stderr)

horses.cpp: In function 'int compute()':
horses.cpp:21:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<double>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |  for (int j = 0; j < lX.size(); j ++) {
      |                  ~~^~~~~~~~~~~
#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...