Submission #719456

# Submission time Handle Problem Language Result Execution time Memory
719456 2023-04-05T23:03:25 Z thimote75 Horses (IOI15_horses) C++14
34 / 100
1500 ms 31636 KB
#include "horses.h"

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

#define ld long double
#define num long long

const num MOD = 1e9 + 7;

vector<num> X;
vector<num> Y;
vector<ld> lX;
vector<ld> lY;

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

	num prod_v = 1;
	num mx_p_v = 1;

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

		prod_v *= X[j];
		prod_v %= MOD;

		if (cur_v > max_v) {
			max_v = cur_v;

			mx_p_v = (prod_v * Y[j]) % MOD;
		}
	}
	return mx_p_v;
}

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

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

	return compute();
}

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

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

Compilation message

horses.cpp: In function 'int compute()':
horses.cpp:23:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long double>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |  for (int j = 0; j < lX.size(); j ++) {
      |                  ~~^~~~~~~~~~~
horses.cpp:36:9: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   36 |  return mx_p_v;
      |         ^~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 224 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 228 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 296 KB Output is correct
23 Correct 11 ms 340 KB Output is correct
24 Correct 10 ms 404 KB Output is correct
25 Correct 8 ms 464 KB Output is correct
26 Correct 11 ms 340 KB Output is correct
27 Correct 6 ms 316 KB Output is correct
28 Correct 7 ms 340 KB Output is correct
29 Correct 6 ms 340 KB Output is correct
30 Correct 6 ms 340 KB Output is correct
31 Correct 6 ms 340 KB Output is correct
32 Correct 6 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1559 ms 27704 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 8 ms 308 KB Output is correct
24 Correct 7 ms 384 KB Output is correct
25 Correct 7 ms 312 KB Output is correct
26 Correct 10 ms 396 KB Output is correct
27 Correct 9 ms 376 KB Output is correct
28 Correct 9 ms 340 KB Output is correct
29 Correct 9 ms 308 KB Output is correct
30 Correct 9 ms 312 KB Output is correct
31 Correct 7 ms 360 KB Output is correct
32 Correct 6 ms 340 KB Output is correct
33 Execution timed out 1557 ms 31636 KB Time limit exceeded
34 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 268 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 9 ms 340 KB Output is correct
24 Correct 7 ms 372 KB Output is correct
25 Correct 9 ms 340 KB Output is correct
26 Correct 7 ms 340 KB Output is correct
27 Correct 7 ms 340 KB Output is correct
28 Correct 8 ms 340 KB Output is correct
29 Correct 7 ms 340 KB Output is correct
30 Correct 7 ms 312 KB Output is correct
31 Correct 6 ms 372 KB Output is correct
32 Correct 6 ms 308 KB Output is correct
33 Execution timed out 1566 ms 29868 KB Time limit exceeded
34 Halted 0 ms 0 KB -