#include "horses.h"
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
const ll mod=1e9+7;
const ll sz=5e5+5;
struct d
{
double sum, lpre;
ll mul, pre;
};
d st[sz*4];
ll x[sz], y[sz], n;
double xl[sz], yl[sz];
d make(ll pos)
{
d cur;
cur.sum=xl[pos];
cur.mul=x[pos];
cur.lpre=xl[pos]+yl[pos];
cur.pre=(x[pos]*y[pos])%mod;
return cur;
}
void mrg(d a, d b, d &c)
{
c.sum=a.sum+b.sum;
c.mul=(a.mul*b.mul)%mod;
if(a.lpre>a.sum+b.lpre){
c.lpre=a.lpre;
c.pre=a.pre;
}
else{
c.lpre=a.sum+b.lpre;
c.pre=(a.mul*b.pre)%mod;
}
}
void build(ll l, ll r, ll in)
{
if(l==r){
st[in]=make(l);
return;
}
ll mid=(l+r)/2;
build(l, mid, in*2);
build(mid+1, r, in*2+1);
mrg(st[in*2], st[in*2+1], st[in]);
}
void update(ll l, ll r, ll in, ll pos)
{
if(l==r){
st[in]=make(l);
return;
}
ll mid=(l+r)/2;
if(pos<=mid){
update(l, mid, in*2, pos);
}
else{
update(mid+1, r, in*2+1, pos);
}
mrg(st[in*2], st[in*2+1], st[in]);
}
int init(int N, int X[], int Y[]) {
ll num=1, ans=0;
n=N;
for(int i=0; i<n; i++){
x[i+1]=(X[i]);
y[i+1]=(Y[i]);
xl[i+1]=log10(X[i]);
yl[i+1]=log10(Y[i]);
}
build(1, n, 1);
return st[1].pre;
}
int updateX(int pos, int val) {
pos++;
x[pos]=val;
xl[pos]=log10(val);
update(1, n, 1, pos);
return st[1].pre;
}
int updateY(int pos, int val) {
pos++;
y[pos]=val;
yl[pos]=log10(val);
update(1, n, 1, pos);
return st[1].pre;
}
Compilation message
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:75:15: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
75 | return st[1].pre;
| ~~~~~~^~~
horses.cpp:66:8: warning: unused variable 'num' [-Wunused-variable]
66 | ll num=1, ans=0;
| ^~~
horses.cpp:66:15: warning: unused variable 'ans' [-Wunused-variable]
66 | ll num=1, ans=0;
| ^~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:83:15: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
83 | return st[1].pre;
| ~~~~~~^~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:91:15: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
91 | return st[1].pre;
| ~~~~~~^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
8540 KB |
Output is correct |
2 |
Correct |
1 ms |
8540 KB |
Output is correct |
3 |
Correct |
1 ms |
8540 KB |
Output is correct |
4 |
Correct |
1 ms |
8636 KB |
Output is correct |
5 |
Correct |
1 ms |
8540 KB |
Output is correct |
6 |
Correct |
1 ms |
8540 KB |
Output is correct |
7 |
Correct |
1 ms |
8540 KB |
Output is correct |
8 |
Correct |
1 ms |
8540 KB |
Output is correct |
9 |
Correct |
1 ms |
8540 KB |
Output is correct |
10 |
Correct |
1 ms |
8540 KB |
Output is correct |
11 |
Correct |
1 ms |
8540 KB |
Output is correct |
12 |
Correct |
1 ms |
8540 KB |
Output is correct |
13 |
Correct |
1 ms |
8540 KB |
Output is correct |
14 |
Correct |
1 ms |
8540 KB |
Output is correct |
15 |
Correct |
1 ms |
8540 KB |
Output is correct |
16 |
Correct |
1 ms |
8540 KB |
Output is correct |
17 |
Correct |
1 ms |
8540 KB |
Output is correct |
18 |
Correct |
1 ms |
8540 KB |
Output is correct |
19 |
Correct |
1 ms |
8540 KB |
Output is correct |
20 |
Correct |
1 ms |
8540 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
8540 KB |
Output is correct |
2 |
Correct |
1 ms |
8540 KB |
Output is correct |
3 |
Correct |
1 ms |
8540 KB |
Output is correct |
4 |
Correct |
1 ms |
8540 KB |
Output is correct |
5 |
Correct |
1 ms |
8540 KB |
Output is correct |
6 |
Correct |
1 ms |
8540 KB |
Output is correct |
7 |
Correct |
1 ms |
8540 KB |
Output is correct |
8 |
Correct |
1 ms |
8540 KB |
Output is correct |
9 |
Correct |
1 ms |
8540 KB |
Output is correct |
10 |
Correct |
1 ms |
8540 KB |
Output is correct |
11 |
Correct |
1 ms |
8540 KB |
Output is correct |
12 |
Correct |
1 ms |
8540 KB |
Output is correct |
13 |
Correct |
1 ms |
8540 KB |
Output is correct |
14 |
Correct |
1 ms |
8540 KB |
Output is correct |
15 |
Correct |
1 ms |
8540 KB |
Output is correct |
16 |
Correct |
1 ms |
8540 KB |
Output is correct |
17 |
Correct |
1 ms |
8540 KB |
Output is correct |
18 |
Correct |
1 ms |
8540 KB |
Output is correct |
19 |
Correct |
1 ms |
8540 KB |
Output is correct |
20 |
Correct |
1 ms |
8540 KB |
Output is correct |
21 |
Correct |
1 ms |
8540 KB |
Output is correct |
22 |
Correct |
1 ms |
8536 KB |
Output is correct |
23 |
Correct |
1 ms |
8540 KB |
Output is correct |
24 |
Correct |
1 ms |
8540 KB |
Output is correct |
25 |
Correct |
1 ms |
8540 KB |
Output is correct |
26 |
Correct |
1 ms |
8540 KB |
Output is correct |
27 |
Correct |
1 ms |
8540 KB |
Output is correct |
28 |
Correct |
1 ms |
8540 KB |
Output is correct |
29 |
Correct |
1 ms |
8540 KB |
Output is correct |
30 |
Correct |
1 ms |
8540 KB |
Output is correct |
31 |
Correct |
1 ms |
8540 KB |
Output is correct |
32 |
Correct |
2 ms |
8676 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
57 ms |
53744 KB |
Output is correct |
2 |
Correct |
111 ms |
53708 KB |
Output is correct |
3 |
Correct |
81 ms |
53844 KB |
Output is correct |
4 |
Correct |
96 ms |
53632 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
8540 KB |
Output is correct |
2 |
Correct |
1 ms |
8540 KB |
Output is correct |
3 |
Correct |
1 ms |
8540 KB |
Output is correct |
4 |
Correct |
1 ms |
8540 KB |
Output is correct |
5 |
Correct |
1 ms |
8540 KB |
Output is correct |
6 |
Correct |
1 ms |
8540 KB |
Output is correct |
7 |
Correct |
1 ms |
8540 KB |
Output is correct |
8 |
Correct |
1 ms |
8540 KB |
Output is correct |
9 |
Correct |
1 ms |
8540 KB |
Output is correct |
10 |
Correct |
1 ms |
8540 KB |
Output is correct |
11 |
Correct |
1 ms |
8540 KB |
Output is correct |
12 |
Correct |
1 ms |
8540 KB |
Output is correct |
13 |
Correct |
1 ms |
8540 KB |
Output is correct |
14 |
Correct |
1 ms |
8540 KB |
Output is correct |
15 |
Correct |
1 ms |
8540 KB |
Output is correct |
16 |
Correct |
1 ms |
8536 KB |
Output is correct |
17 |
Correct |
1 ms |
8540 KB |
Output is correct |
18 |
Correct |
1 ms |
8540 KB |
Output is correct |
19 |
Correct |
1 ms |
8540 KB |
Output is correct |
20 |
Correct |
1 ms |
8540 KB |
Output is correct |
21 |
Correct |
1 ms |
8540 KB |
Output is correct |
22 |
Correct |
1 ms |
8540 KB |
Output is correct |
23 |
Correct |
2 ms |
8652 KB |
Output is correct |
24 |
Correct |
2 ms |
8540 KB |
Output is correct |
25 |
Correct |
2 ms |
8540 KB |
Output is correct |
26 |
Correct |
2 ms |
8540 KB |
Output is correct |
27 |
Correct |
2 ms |
8540 KB |
Output is correct |
28 |
Correct |
1 ms |
8540 KB |
Output is correct |
29 |
Correct |
1 ms |
8672 KB |
Output is correct |
30 |
Correct |
2 ms |
8540 KB |
Output is correct |
31 |
Correct |
1 ms |
8540 KB |
Output is correct |
32 |
Correct |
2 ms |
8540 KB |
Output is correct |
33 |
Correct |
49 ms |
52880 KB |
Output is correct |
34 |
Correct |
47 ms |
52820 KB |
Output is correct |
35 |
Correct |
62 ms |
52908 KB |
Output is correct |
36 |
Correct |
66 ms |
52816 KB |
Output is correct |
37 |
Correct |
35 ms |
52828 KB |
Output is correct |
38 |
Correct |
39 ms |
52816 KB |
Output is correct |
39 |
Correct |
33 ms |
52856 KB |
Output is correct |
40 |
Correct |
48 ms |
52816 KB |
Output is correct |
41 |
Correct |
31 ms |
52896 KB |
Output is correct |
42 |
Correct |
31 ms |
52944 KB |
Output is correct |
43 |
Correct |
45 ms |
52684 KB |
Output is correct |
44 |
Correct |
43 ms |
52816 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
8540 KB |
Output is correct |
2 |
Correct |
1 ms |
8540 KB |
Output is correct |
3 |
Correct |
1 ms |
8540 KB |
Output is correct |
4 |
Correct |
1 ms |
8540 KB |
Output is correct |
5 |
Correct |
1 ms |
8540 KB |
Output is correct |
6 |
Correct |
1 ms |
8540 KB |
Output is correct |
7 |
Correct |
1 ms |
8540 KB |
Output is correct |
8 |
Correct |
1 ms |
8540 KB |
Output is correct |
9 |
Correct |
1 ms |
8540 KB |
Output is correct |
10 |
Correct |
1 ms |
8540 KB |
Output is correct |
11 |
Correct |
1 ms |
8540 KB |
Output is correct |
12 |
Correct |
1 ms |
8540 KB |
Output is correct |
13 |
Correct |
1 ms |
8540 KB |
Output is correct |
14 |
Correct |
1 ms |
8540 KB |
Output is correct |
15 |
Correct |
1 ms |
8540 KB |
Output is correct |
16 |
Correct |
1 ms |
8540 KB |
Output is correct |
17 |
Correct |
1 ms |
8540 KB |
Output is correct |
18 |
Correct |
1 ms |
8536 KB |
Output is correct |
19 |
Correct |
1 ms |
8540 KB |
Output is correct |
20 |
Correct |
1 ms |
8540 KB |
Output is correct |
21 |
Correct |
1 ms |
8540 KB |
Output is correct |
22 |
Correct |
1 ms |
8540 KB |
Output is correct |
23 |
Correct |
1 ms |
8540 KB |
Output is correct |
24 |
Correct |
1 ms |
8540 KB |
Output is correct |
25 |
Correct |
1 ms |
8540 KB |
Output is correct |
26 |
Correct |
1 ms |
8540 KB |
Output is correct |
27 |
Correct |
1 ms |
8540 KB |
Output is correct |
28 |
Correct |
1 ms |
8536 KB |
Output is correct |
29 |
Correct |
1 ms |
8540 KB |
Output is correct |
30 |
Correct |
1 ms |
8540 KB |
Output is correct |
31 |
Correct |
1 ms |
8540 KB |
Output is correct |
32 |
Correct |
1 ms |
8540 KB |
Output is correct |
33 |
Correct |
52 ms |
53640 KB |
Output is correct |
34 |
Correct |
102 ms |
53584 KB |
Output is correct |
35 |
Correct |
76 ms |
53700 KB |
Output is correct |
36 |
Correct |
93 ms |
53840 KB |
Output is correct |
37 |
Correct |
41 ms |
52816 KB |
Output is correct |
38 |
Correct |
41 ms |
52820 KB |
Output is correct |
39 |
Correct |
57 ms |
52816 KB |
Output is correct |
40 |
Correct |
57 ms |
52912 KB |
Output is correct |
41 |
Correct |
32 ms |
53072 KB |
Output is correct |
42 |
Correct |
36 ms |
52828 KB |
Output is correct |
43 |
Correct |
30 ms |
52716 KB |
Output is correct |
44 |
Correct |
46 ms |
52696 KB |
Output is correct |
45 |
Correct |
28 ms |
52820 KB |
Output is correct |
46 |
Correct |
28 ms |
52948 KB |
Output is correct |
47 |
Correct |
40 ms |
52680 KB |
Output is correct |
48 |
Correct |
45 ms |
52820 KB |
Output is correct |
49 |
Correct |
91 ms |
53712 KB |
Output is correct |
50 |
Correct |
91 ms |
53656 KB |
Output is correct |
51 |
Correct |
79 ms |
53844 KB |
Output is correct |
52 |
Correct |
86 ms |
53844 KB |
Output is correct |
53 |
Correct |
92 ms |
53728 KB |
Output is correct |
54 |
Correct |
75 ms |
53840 KB |
Output is correct |
55 |
Correct |
45 ms |
52828 KB |
Output is correct |
56 |
Correct |
76 ms |
53720 KB |
Output is correct |
57 |
Correct |
50 ms |
53588 KB |
Output is correct |
58 |
Correct |
54 ms |
53840 KB |
Output is correct |
59 |
Correct |
45 ms |
52816 KB |
Output is correct |