답안 #1004913

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1004913 2024-06-22T03:12:32 Z pawned 말 (IOI15_horses) C++17
34 / 100
1500 ms 16096 KB
#pragma GCC optimize("O1,O2,O3,Ofast,unroll-loops")

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

#define fi first
#define se second
#define pb push_back
typedef long long ll;
typedef pair<ll, ll> ii;
typedef vector<ll> vi;

#include "horses.h"

const ll MOD = 1e9 + 7;
const ll MAX = 1e9 + 5;

ll norm(ll x) {
	x %= MOD;
	x += MOD;
	x %= MOD;
	return x;
}

int N;

vi X;
vi Y;

ll solve() {
	int bestp = N - 1;
	ll currn = Y[N - 1];
	ll currd = 1;
	ll bestn = currn;
	ll bestd = currd;
	for (int i = N - 2; i >= 0; i--) {
		currn = Y[i];
		currd *= X[i + 1];
		if (currd >= MAX)
			break;
		if (currn * bestd > bestn * currd) {
			bestp = i;
			bestn = currn;
			bestd = currd;
		}
	}
	ll ans = 1;
	for (int i = 0; i <= bestp; i++) {
		ans *= X[i];
		ans = norm(ans);
	}
	ans *= Y[bestp];
	ans = norm(ans);
	return ans;
}

int init(int n, int x[], int y[]) {
	N = n;
	X = vi(N); Y = vi(N);
	for (int i = 0; i < N; i++) {
		X[i] = x[i];
		Y[i] = y[i];
	}
	ll ans = solve();
	return (int)(ans);
}

int updateX(int pos, int val) {
	X[pos] = val;
	ll ans = solve();
	return (int)(ans);
}

int updateY(int pos, int val) {
	Y[pos] = val;
	ll ans = solve();
	return (int)(ans);
}
# 결과 실행 시간 메모리 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 344 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 1 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 424 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 1 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 436 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 432 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 440 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 8 ms 348 KB Output is correct
24 Correct 9 ms 476 KB Output is correct
25 Correct 8 ms 348 KB Output is correct
26 Correct 8 ms 348 KB Output is correct
27 Correct 8 ms 472 KB Output is correct
28 Correct 8 ms 348 KB Output is correct
29 Correct 10 ms 468 KB Output is correct
30 Correct 9 ms 348 KB Output is correct
31 Correct 4 ms 348 KB Output is correct
32 Correct 7 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1568 ms 14336 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 604 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 436 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 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 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 432 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 8 ms 348 KB Output is correct
24 Correct 8 ms 348 KB Output is correct
25 Correct 8 ms 348 KB Output is correct
26 Correct 8 ms 348 KB Output is correct
27 Correct 8 ms 348 KB Output is correct
28 Correct 8 ms 348 KB Output is correct
29 Correct 9 ms 348 KB Output is correct
30 Correct 8 ms 348 KB Output is correct
31 Correct 4 ms 348 KB Output is correct
32 Correct 7 ms 348 KB Output is correct
33 Execution timed out 1589 ms 16096 KB Time limit exceeded
34 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 344 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 344 KB Output is correct
23 Correct 8 ms 344 KB Output is correct
24 Correct 8 ms 348 KB Output is correct
25 Correct 8 ms 492 KB Output is correct
26 Correct 8 ms 348 KB Output is correct
27 Correct 7 ms 348 KB Output is correct
28 Correct 8 ms 348 KB Output is correct
29 Correct 10 ms 348 KB Output is correct
30 Correct 8 ms 348 KB Output is correct
31 Correct 4 ms 348 KB Output is correct
32 Correct 7 ms 348 KB Output is correct
33 Execution timed out 1593 ms 14352 KB Time limit exceeded
34 Halted 0 ms 0 KB -