This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "horses.h"
#include <bits/stdc++.h>
typedef long double ld;
typedef long long ll;
using namespace std;
const int MAXN = 111111;
const int MOD = 1000000007;
int X[MAXN], Y[MAXN];
int N;
int calc(){
ld best = 0, mult = 0;
for (int i = 0; i < N; i++){
mult += log2(X[i]);
best = max(best, mult + log2(Y[i]));
}
ll ans = 1;
mult = 0;
for (int i = 0; i < N; i++){
mult += log2(X[i]);
ans = (ans * X[i]) % MOD;
if (mult + log2(Y[i]) == best){
ans = (ans * Y[i]) % MOD;
return ans;
}
}
return 0;
}
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 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 (stderr)
horses.cpp: In function 'int calc()':
horses.cpp:31:20: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
31 | return ans;
| ^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |