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>
#define fo(a,b,c) for (int a=b;a<=c;a++)
using namespace std;
const int MAXN = 5e5+5,mod = 1e9+7;
typedef long long ll;
int n,x[MAXN],y[MAXN];
int sol()
{
ll k = 0;
ll res = -1;
ll q=1;
fo(i,max(0,n-1-35),n-1) {
q *= x[i];
if (k<=q) {
res = i;
k = y[i];
q = 1;
} else {
q *= y[i];
if (k<=q) {
res = i;
k = y[i];
q = 1;
} else {
q /= y[i];
}
}
}
ll r = 1;
fo(i,0,res) {
r *= x[i];
r %= mod;
}
r *= y[res];
r %= mod;
return r;
}
int init(int N, int X[], int Y[]) {
n = N;
fo(i,0,n-1) x[i] = X[i];
fo(i,0,n-1) y[i] = Y[i];
return sol();
}
int updateX(int pos, int val) {
x[pos] = val;
return sol();
}
int updateY(int pos, int val) {
y[pos] = val;
return sol();
}
Compilation message (stderr)
horses.cpp: In function 'int sol()':
horses.cpp:37:9: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
37 | return r;
| ^
# | 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... |