Submission #718545

# Submission time Handle Problem Language Result Execution time Memory
718545 2023-04-04T09:58:23 Z mseebacher Horses (IOI15_horses) C++17
34 / 100
1500 ms 12016 KB
#include "horses.h"
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <functional>
#include <iostream>
#include <fstream>
#include <string>

using namespace std;

vector<int> x;
vector<int> y;
int n;


const int MOD = 1e9+7;

int calc(){
	double horses_log = log2(1);
	double p_log = -1e18;
	long long horses_mod = 1;
	long long p_mod = -1e18;
	for(int i = 0;i<n;i++){
		horses_log += log2(x[i]);
		horses_mod = horses_mod * x[i] %MOD;
		if(horses_log + log2(y[i]) > p_log){
			p_log = horses_log+log2(y[i]);
			p_mod = horses_mod*y[i] %MOD;
		}
	}
	return p_mod%MOD;
}

int init(int N, int X[], int Y[]) {
	n = N;
	x.assign(N,0);
	y.assign(N,0);
	for(int i = 0;i<n;i++){
		x[i] = X[i];
		y[i] = Y[i];
	}
	return calc();
}

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

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

Compilation message

horses.cpp: In function 'int calc()':
horses.cpp:42:14: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   42 |  return p_mod%MOD;
      |         ~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 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 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 0 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 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 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 0 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 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 0 ms 212 KB Output is correct
17 Correct 0 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
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 22 ms 212 KB Output is correct
24 Correct 21 ms 312 KB Output is correct
25 Correct 32 ms 340 KB Output is correct
26 Correct 32 ms 348 KB Output is correct
27 Correct 11 ms 336 KB Output is correct
28 Correct 34 ms 336 KB Output is correct
29 Correct 6 ms 212 KB Output is correct
30 Correct 13 ms 336 KB Output is correct
31 Correct 8 ms 340 KB Output is correct
32 Correct 9 ms 312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1577 ms 8040 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 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 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 0 ms 212 KB Output is correct
12 Correct 1 ms 216 KB Output is correct
13 Correct 0 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 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 212 KB Output is correct
23 Correct 21 ms 340 KB Output is correct
24 Correct 25 ms 436 KB Output is correct
25 Correct 34 ms 340 KB Output is correct
26 Correct 32 ms 352 KB Output is correct
27 Correct 15 ms 340 KB Output is correct
28 Correct 34 ms 324 KB Output is correct
29 Correct 7 ms 308 KB Output is correct
30 Correct 15 ms 340 KB Output is correct
31 Correct 7 ms 340 KB Output is correct
32 Correct 8 ms 316 KB Output is correct
33 Execution timed out 1553 ms 12016 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 0 ms 212 KB Output is correct
3 Correct 0 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 0 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 0 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 0 ms 212 KB Output is correct
17 Correct 0 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 1 ms 212 KB Output is correct
23 Correct 26 ms 312 KB Output is correct
24 Correct 22 ms 344 KB Output is correct
25 Correct 44 ms 340 KB Output is correct
26 Correct 47 ms 340 KB Output is correct
27 Correct 12 ms 340 KB Output is correct
28 Correct 34 ms 212 KB Output is correct
29 Correct 6 ms 308 KB Output is correct
30 Correct 13 ms 340 KB Output is correct
31 Correct 8 ms 332 KB Output is correct
32 Correct 8 ms 340 KB Output is correct
33 Execution timed out 1562 ms 10292 KB Time limit exceeded
34 Halted 0 ms 0 KB -