답안 #1041910

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1041910 2024-08-02T10:08:51 Z fv3 말 (IOI15_horses) C++14
34 / 100
1500 ms 24148 KB
#include <bits/stdc++.h>
#include "horses.h"

using namespace std;
typedef long long ll;

const ll mod = 1e9 + 7;
int N; vector<ll> X, Y;

int nt = 1;
vector<ll> st;

ll get_range(int l, int r, int k, int x, int y)
{
	if (y < l || x > r) return 1;
	if (x >= l && y <= r) return st[k];
	int c = (x + y) / 2;
	return get_range(l, r, k*2, x, c) * get_range(l, r, k*2|1, c+1, y);
}

int get_max()
{
	ll res = (X[0] * Y[0]) % mod, cnt = X[0];
	int mx_index = 0;

	for (int i = 1; i < N; i++)
	{
		cnt = (cnt * X[i]) % mod;
		ll last_mult = Y[mx_index];

		ll mult_range = get_range(mx_index + 1, i, 1, 0, nt - 1); 

		if (mult_range >= last_mult || mult_range * Y[i] >= last_mult)
		{
			res = (cnt * Y[i]) % mod;
			mx_index = i;
		}
	}

	return (int)res;
}

int init(int n, int x[], int y[]) 
{
	N = n;
	X.resize(N);
	Y.resize(N);

	for (int i = 0; i < N; i++)
	{
		X[i] = x[i];
		Y[i] = y[i];
	}

	while (nt < N) nt <<= 1;
	st = vector<ll>(2 * nt, 1);
	for (int i = 0; i < N; i++)
		st[nt + i] = X[i];
	for (int i = nt-1; i >= 1; i--)
		st[i] = st[i*2] * st[i*2|1];

	return get_max();
}

int updateX(int pos, int val) 
{
	X[pos] = val;
	pos += nt;
	st[pos] = val;

	for (pos /= 2; pos >= 1; pos /= 2)
		st[pos] = st[pos*2] * st[pos*2|1];

	return get_max();
}

int updateY(int pos, int val) 
{
	Y[pos] = val;
	return get_max();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 436 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 39 ms 348 KB Output is correct
24 Correct 39 ms 348 KB Output is correct
25 Correct 34 ms 348 KB Output is correct
26 Correct 34 ms 348 KB Output is correct
27 Correct 56 ms 476 KB Output is correct
28 Correct 36 ms 348 KB Output is correct
29 Correct 34 ms 348 KB Output is correct
30 Correct 34 ms 348 KB Output is correct
31 Correct 61 ms 348 KB Output is correct
32 Correct 68 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1536 ms 20312 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 52 ms 348 KB Output is correct
24 Correct 39 ms 348 KB Output is correct
25 Correct 39 ms 348 KB Output is correct
26 Correct 34 ms 344 KB Output is correct
27 Correct 51 ms 348 KB Output is correct
28 Correct 34 ms 344 KB Output is correct
29 Correct 36 ms 348 KB Output is correct
30 Correct 40 ms 476 KB Output is correct
31 Correct 72 ms 344 KB Output is correct
32 Correct 72 ms 348 KB Output is correct
33 Execution timed out 1551 ms 24148 KB Time limit exceeded
34 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 436 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 39 ms 500 KB Output is correct
24 Correct 38 ms 348 KB Output is correct
25 Correct 35 ms 348 KB Output is correct
26 Correct 35 ms 348 KB Output is correct
27 Correct 50 ms 348 KB Output is correct
28 Correct 35 ms 344 KB Output is correct
29 Correct 34 ms 348 KB Output is correct
30 Correct 34 ms 496 KB Output is correct
31 Correct 60 ms 348 KB Output is correct
32 Correct 70 ms 344 KB Output is correct
33 Execution timed out 1588 ms 22360 KB Time limit exceeded
34 Halted 0 ms 0 KB -