#include "horses.h"
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int n;
vector<ll> x, y, tr;
void build(int v, int l, int r){
if (l == r){
tr[v] = x[l];
}
int mid = (l + r) / 2;
build(v * 2, l, mid);
build(v * 2, mid + 1, r);
tr[v] = (tr[v * 2] * tr[v * 2 + 1]) % mod;
}
void update(int v, int l, int r, int pos, ll val){
if (l == r){
tr[v] = val;
}
else{
int mid = (l + r) / 2;
if (pos <= mid){
update(v * 2, l, mid, pos, val);
}
else{
update(v * 2 + 2, mid + 1, r, pos, val);
}
tr[v] = (tr[v * 2] * tr[v * 2 + 1]) % mod;
}
}
ll query(int v, int l, int r, int ql, int qr){
if (l > qr || r < ql){
return 1;
}
else if (ql <= l && r <= qr){
return tr[v];
}
int mid = (l + r) / 2;
return (query(v * 2, l, mid, ql, qr) * query(v * 2 + 1, mid + 1, r, ql, qr)) % mod;
}
ll calc(){
ll ti = 1, in = n;
for (int i = n; i >= 0; i++){
ti *= x[i];
if (ti < mod){
in--;
}
else{
break;
}
}
ll ma = 0;
ll prmult = 1;
for (int i = 0; i < n; i++){
prmult *= x[i];
ma = max(ma, 1ll * prmult * y[i]);
}
ll ext = 1;
if (ti != 0){
ext = query(1, 0, n - 1, 0, ti - 1);
}
return ((ma % mod) * ext) % mod;
}
int init(int N, int X[], int Y[]) {
n = N;
x.resize(N), y.resize(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;
update(1, 0, n - 1, pos, val);
return calc();
}
int updateY(int pos, int val) {
y[pos] = val;
return calc();
}
Compilation message
horses.cpp: In function 'long long int calc()':
horses.cpp:61:34: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
61 | ext = query(1, 0, n - 1, 0, ti - 1);
| ~~~^~~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:72:13: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
72 | return calc();
| ~~~~^~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:78:13: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
78 | return calc();
| ~~~~^~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:83:13: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
83 | return calc();
| ~~~~^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
24 ms |
26460 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
0 ms |
348 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |