#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;
| ~~~~~~^~~
# |
결과 |
실행 시간 |
메모리 |
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 |
# |
결과 |
실행 시간 |
메모리 |
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 |
8640 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 |
8648 KB |
Output is correct |
18 |
Correct |
1 ms |
8624 KB |
Output is correct |
19 |
Correct |
1 ms |
8540 KB |
Output is correct |
20 |
Correct |
1 ms |
8536 KB |
Output is correct |
21 |
Correct |
1 ms |
8540 KB |
Output is correct |
22 |
Correct |
1 ms |
8644 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 |
1 ms |
8540 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
58 ms |
53588 KB |
Output is correct |
2 |
Correct |
114 ms |
53724 KB |
Output is correct |
3 |
Correct |
89 ms |
53840 KB |
Output is correct |
4 |
Correct |
101 ms |
53844 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
8536 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 |
8636 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 |
8536 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 |
1 ms |
8540 KB |
Output is correct |
33 |
Correct |
45 ms |
52788 KB |
Output is correct |
34 |
Correct |
43 ms |
52824 KB |
Output is correct |
35 |
Correct |
63 ms |
52828 KB |
Output is correct |
36 |
Correct |
62 ms |
52820 KB |
Output is correct |
37 |
Correct |
34 ms |
52760 KB |
Output is correct |
38 |
Correct |
39 ms |
52816 KB |
Output is correct |
39 |
Correct |
30 ms |
52816 KB |
Output is correct |
40 |
Correct |
45 ms |
52724 KB |
Output is correct |
41 |
Correct |
30 ms |
52820 KB |
Output is correct |
42 |
Correct |
31 ms |
52820 KB |
Output is correct |
43 |
Correct |
50 ms |
52820 KB |
Output is correct |
44 |
Correct |
44 ms |
52820 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
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 |
8536 KB |
Output is correct |
7 |
Correct |
1 ms |
8536 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 |
8648 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 |
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 |
8548 KB |
Output is correct |
26 |
Correct |
1 ms |
8544 KB |
Output is correct |
27 |
Correct |
2 ms |
8548 KB |
Output is correct |
28 |
Correct |
1 ms |
8548 KB |
Output is correct |
29 |
Correct |
1 ms |
8548 KB |
Output is correct |
30 |
Correct |
1 ms |
8548 KB |
Output is correct |
31 |
Correct |
1 ms |
8544 KB |
Output is correct |
32 |
Correct |
1 ms |
8548 KB |
Output is correct |
33 |
Correct |
59 ms |
53752 KB |
Output is correct |
34 |
Correct |
114 ms |
53712 KB |
Output is correct |
35 |
Correct |
80 ms |
53588 KB |
Output is correct |
36 |
Correct |
99 ms |
53588 KB |
Output is correct |
37 |
Correct |
45 ms |
53072 KB |
Output is correct |
38 |
Correct |
42 ms |
52816 KB |
Output is correct |
39 |
Correct |
54 ms |
52936 KB |
Output is correct |
40 |
Correct |
61 ms |
52820 KB |
Output is correct |
41 |
Correct |
34 ms |
52820 KB |
Output is correct |
42 |
Correct |
36 ms |
52816 KB |
Output is correct |
43 |
Correct |
35 ms |
52816 KB |
Output is correct |
44 |
Correct |
46 ms |
52820 KB |
Output is correct |
45 |
Correct |
32 ms |
52748 KB |
Output is correct |
46 |
Correct |
37 ms |
52880 KB |
Output is correct |
47 |
Correct |
45 ms |
52680 KB |
Output is correct |
48 |
Correct |
44 ms |
52820 KB |
Output is correct |
49 |
Correct |
98 ms |
53844 KB |
Output is correct |
50 |
Correct |
93 ms |
53712 KB |
Output is correct |
51 |
Correct |
85 ms |
53844 KB |
Output is correct |
52 |
Correct |
83 ms |
53780 KB |
Output is correct |
53 |
Correct |
80 ms |
53832 KB |
Output is correct |
54 |
Correct |
70 ms |
53724 KB |
Output is correct |
55 |
Correct |
50 ms |
52816 KB |
Output is correct |
56 |
Correct |
70 ms |
53584 KB |
Output is correct |
57 |
Correct |
57 ms |
53588 KB |
Output is correct |
58 |
Correct |
53 ms |
53852 KB |
Output is correct |
59 |
Correct |
45 ms |
52684 KB |
Output is correct |