Submission #764781

# Submission time Handle Problem Language Result Execution time Memory
764781 2023-06-24T04:13:56 Z SanguineChameleon Horses (IOI15_horses) C++17
34 / 100
1500 ms 11960 KB
#include "horses.h"
#include <bits/stdc++.h>
using namespace std;

const int mod = 1e9 + 7;

int mul(int a, int b) {
	if (a > mod / b) {
		return mod;
	}
	else {
		return a * b;
	}
}

const int maxN = 5e5 + 20;
int X[maxN];
int Y[maxN];
int N;

int calc() {
	int best = 1;
	int gain = 1;
	for (int i = 2; i <= N; i++) {
		gain = mul(gain, X[i]);
		if (mul(gain, Y[i]) > Y[best]) {
			best = i;
			gain = 1;
		}
	}
	int res = 1;
	for (int i = 1; i <= best; i++) {
		res = 1LL * res * X[i] % mod;
	}
	res = 1LL * res * Y[best] % mod;
	return res;
}

int init(int _N, int _X[], int _Y[]) {
	N = _N;
	for (int i = 1; i <= N; i++) {
		X[i] = _X[i - 1];
		Y[i] = _Y[i - 1];
	}
	return calc();
}

int updateX(int pos, int val) {	
	pos++;
	X[pos] = val;
	return calc();
}

int updateY(int pos, int val) {
	pos++;
	Y[pos] = val;
	return calc();
}

Compilation message

horses.cpp: In function 'int calc()':
horses.cpp:33:26: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   33 |   res = 1LL * res * X[i] % mod;
      |         ~~~~~~~~~~~~~~~~~^~~~~
horses.cpp:35:28: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   35 |  res = 1LL * res * Y[best] % mod;
      |        ~~~~~~~~~~~~~~~~~~~~^~~~~
# 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 1 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 1 ms 284 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 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 312 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 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 1 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 1 ms 212 KB Output is correct
4 Correct 0 ms 312 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 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 0 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 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 212 KB Output is correct
16 Correct 1 ms 316 KB Output is correct
17 Correct 1 ms 316 KB Output is correct
18 Correct 0 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 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 20 ms 320 KB Output is correct
24 Correct 20 ms 364 KB Output is correct
25 Correct 14 ms 376 KB Output is correct
26 Correct 14 ms 364 KB Output is correct
27 Correct 21 ms 352 KB Output is correct
28 Correct 21 ms 352 KB Output is correct
29 Correct 20 ms 352 KB Output is correct
30 Correct 19 ms 324 KB Output is correct
31 Correct 19 ms 340 KB Output is correct
32 Correct 20 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1563 ms 10260 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 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 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 308 KB Output is correct
10 Correct 1 ms 312 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 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 0 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 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 312 KB Output is correct
22 Correct 0 ms 308 KB Output is correct
23 Correct 20 ms 360 KB Output is correct
24 Correct 20 ms 340 KB Output is correct
25 Correct 14 ms 368 KB Output is correct
26 Correct 14 ms 320 KB Output is correct
27 Correct 21 ms 340 KB Output is correct
28 Correct 21 ms 348 KB Output is correct
29 Correct 20 ms 340 KB Output is correct
30 Correct 19 ms 340 KB Output is correct
31 Correct 19 ms 328 KB Output is correct
32 Correct 20 ms 352 KB Output is correct
33 Execution timed out 1566 ms 11960 KB Time limit exceeded
34 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 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 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 0 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 1 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 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 20 ms 324 KB Output is correct
24 Correct 20 ms 340 KB Output is correct
25 Correct 14 ms 340 KB Output is correct
26 Correct 14 ms 364 KB Output is correct
27 Correct 21 ms 356 KB Output is correct
28 Correct 21 ms 340 KB Output is correct
29 Correct 20 ms 340 KB Output is correct
30 Correct 19 ms 364 KB Output is correct
31 Correct 19 ms 340 KB Output is correct
32 Correct 20 ms 352 KB Output is correct
33 Execution timed out 1577 ms 10188 KB Time limit exceeded
34 Halted 0 ms 0 KB -