Submission #592229

# Submission time Handle Problem Language Result Execution time Memory
592229 2022-07-08T19:00:18 Z l_reho Horses (IOI15_horses) C++14
17 / 100
1500 ms 8020 KB

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

vector<int> A, B;
int L;

long long MOD = 1000000007;

long long modMult(long long a, long long b){
	a %= MOD;
	b %= MOD;
	
	return ((a%MOD)*(b%MOD))%MOD;
}



long long test(){
	
	long long curr = 1;
	long long best = 0;
	long long pos = -1;
	
	for(int i = 0; i < L; i++){
		curr = modMult(curr, A[i]);
		if(modMult(curr, B[i]) >= best){
			best = B[i];
			curr = 1;
			pos = i;
		}
	}
	
	long long ans = 1LL;
	for(int i = 0; i <= pos; i++){
		ans = modMult(ans, A[i]);
	}
	
	ans = modMult(ans, B[pos]);
	
	return ans%MOD;
}

int init(int N, int X[], int Y[]) {
	A.assign(N, 0);
	B.assign(N, 0);
	L = N;
	
	for(int i = 0; i < N; i++) A[i] = X[i], B[i] = Y[i];
	
	
	return test();
}

int updateX(int pos, int val) {
	A[pos] = val;
	return test();
}

int updateY(int pos, int val) {
	B[pos] = val;
	return test();
}

Compilation message

horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:53:13: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   53 |  return test();
      |         ~~~~^~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:58:13: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   58 |  return test();
      |         ~~~~^~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:63:13: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   63 |  return test();
      |         ~~~~^~
# 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 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 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 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 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 0 ms 212 KB Output is correct
13 Correct 1 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 0 ms 212 KB Output is correct
19 Correct 0 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 Incorrect 1 ms 212 KB Output isn't correct
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1587 ms 8020 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 1 ms 244 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 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 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 Incorrect 1 ms 212 KB Output isn't correct
23 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 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 0 ms 212 KB Output is correct
14 Correct 0 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 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 Incorrect 1 ms 300 KB Output isn't correct
23 Halted 0 ms 0 KB -