Submission #1049827

# Submission time Handle Problem Language Result Execution time Memory
1049827 2024-08-09T05:35:24 Z TAhmed33 Horses (IOI15_horses) C++
34 / 100
1500 ms 12116 KB
#include "horses.h"
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int add (int a, int b) {
	a += b; if (a >= MOD) a -= MOD;
	return a;
}
int sub (int a, int b) {
	a -= b; if (a < 0) a += MOD;
	return a;
}
int mul (int a, int b) {
	return (a * 1ll * b) % MOD;
}
const int MAXN = 5e5 + 25;
int x[MAXN], y[MAXN], n;
int ans () {
	long double s = log2(x[0]);
	long double cur = s + log2(y[0]);
	int pos = 0;
	for (int i = 1; i < n; i++) {
		s += log2(x[i]); 
		long double t = s + log2(y[i]);
		if (t > cur + 1e-9) {
			cur = t; pos = i;
		}
	}
	int ret = 1;
	for (int i = 0; i <= pos; i++) {
		ret = mul(ret, x[i]);
	}
	ret = mul(ret, y[pos]);
	return ret;
}
int init (int N, int X[], int Y[]) {
	n = N;
	for (int i = 0; i < n; i++) {
		x[i] = X[i]; y[i] = Y[i];
	}
	return ans();
}

int updateX (int pos, int val) {	
	x[pos] = val;
	return ans();
}

int updateY (int pos, int val) {
	y[pos] = val;
	return ans();
}

Compilation message

horses.cpp: In function 'int mul(int, int)':
horses.cpp:14:23: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   14 |  return (a * 1ll * b) % MOD;
      |         ~~~~~~~~~~~~~~^~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 0 ms 2400 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 0 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 0 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 0 ms 2396 KB Output is correct
20 Correct 0 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2392 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 0 ms 2400 KB Output is correct
15 Correct 0 ms 2400 KB Output is correct
16 Correct 0 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 0 ms 2400 KB Output is correct
19 Correct 0 ms 2400 KB Output is correct
20 Correct 0 ms 2400 KB Output is correct
21 Correct 0 ms 2396 KB Output is correct
22 Correct 0 ms 2400 KB Output is correct
23 Correct 23 ms 2536 KB Output is correct
24 Correct 21 ms 2536 KB Output is correct
25 Correct 24 ms 2400 KB Output is correct
26 Correct 25 ms 2540 KB Output is correct
27 Correct 17 ms 2524 KB Output is correct
28 Correct 22 ms 2540 KB Output is correct
29 Correct 14 ms 2396 KB Output is correct
30 Correct 17 ms 2396 KB Output is correct
31 Correct 12 ms 2524 KB Output is correct
32 Correct 14 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1560 ms 8280 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2400 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2400 KB Output is correct
6 Correct 0 ms 2400 KB Output is correct
7 Correct 0 ms 2404 KB Output is correct
8 Correct 0 ms 2400 KB Output is correct
9 Correct 0 ms 2476 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 0 ms 2404 KB Output is correct
15 Correct 0 ms 2396 KB Output is correct
16 Correct 0 ms 2396 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 0 ms 2396 KB Output is correct
20 Correct 0 ms 2396 KB Output is correct
21 Correct 0 ms 2396 KB Output is correct
22 Correct 0 ms 2396 KB Output is correct
23 Correct 20 ms 2532 KB Output is correct
24 Correct 20 ms 2544 KB Output is correct
25 Correct 26 ms 2544 KB Output is correct
26 Correct 25 ms 2396 KB Output is correct
27 Correct 16 ms 2392 KB Output is correct
28 Correct 24 ms 2532 KB Output is correct
29 Correct 19 ms 2396 KB Output is correct
30 Correct 17 ms 2532 KB Output is correct
31 Correct 13 ms 2392 KB Output is correct
32 Correct 14 ms 2396 KB Output is correct
33 Execution timed out 1585 ms 12116 KB Time limit exceeded
34 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2400 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 0 ms 2392 KB Output is correct
14 Correct 0 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 0 ms 2404 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Correct 0 ms 2396 KB Output is correct
19 Correct 0 ms 2396 KB Output is correct
20 Correct 0 ms 2396 KB Output is correct
21 Correct 0 ms 2396 KB Output is correct
22 Correct 0 ms 2396 KB Output is correct
23 Correct 20 ms 2536 KB Output is correct
24 Correct 20 ms 2396 KB Output is correct
25 Correct 24 ms 2548 KB Output is correct
26 Correct 24 ms 2544 KB Output is correct
27 Correct 17 ms 2396 KB Output is correct
28 Correct 23 ms 2396 KB Output is correct
29 Correct 14 ms 2520 KB Output is correct
30 Correct 17 ms 2532 KB Output is correct
31 Correct 14 ms 2532 KB Output is correct
32 Correct 14 ms 2396 KB Output is correct
33 Execution timed out 1593 ms 10440 KB Time limit exceeded
34 Halted 0 ms 0 KB -