//每个马在每一个地方都一个价值 找最大的一个地方
// ∏x[i](i->j) * y[j]
#include "horses.h"
#include<bits/stdc++.h>
using namespace std;
const int maxn=5e5+12;
const int mod=1e9+7;
int n,x[maxn],y[maxn];
struct Tree
{
int mx,num;
double val,sum;
}tree[maxn<<2];
void pushup(int now)
{
if(tree[now<<1].val>tree[now<<1].sum+tree[now<<1|1].val)
{
tree[now].val=tree[now<<1].val;
tree[now].mx=tree[now<<1].mx;
}
else
{
tree[now].val=tree[now<<1].sum+tree[now<<1|1].val;
tree[now].mx=1LL*tree[now<<1].num*tree[now<<1|1].mx%mod;
}
tree[now].num=1LL*tree[now<<1].num*tree[now<<1|1].num%mod;
tree[now].sum=tree[now<<1].sum+tree[now<<1|1].sum;
}
void build(int l,int r,int now)
{
if(l==r)
{
tree[now].mx=1LL*x[l]*y[l]%mod;
tree[now].num=x[l];
tree[now].val=log(1.0*x[l]*y[l]);
tree[now].sum=log(1.0*x[l]);
return ;
}
int mid=(l+r)>>1;
build(l,mid,now<<1);build(mid+1,r,now<<1|1);
pushup(now);
}
void updata(int L,int l,int r,int now)
{
if(l==r)
{
tree[now].mx=1LL*x[l]*y[l]%mod;
tree[now].num=x[l];
tree[now].val=log(1.0*x[l]*y[l]);
tree[now].sum=log(1.0*x[l]);//log相加就是相乘
return ;
}
int mid=(l+r)>>1;
if(L<=mid) updata(L,l,mid,now<<1);
else updata(L,mid+1,r,now<<1|1);
pushup(now);
}
int init(int N, int X[], int Y[])
{
n=N;
for(int i=1;i<=n;i++) x[i]=X[i-1],y[i]=Y[i-1];
build(1,n,1);
return tree[1].mx;
}
int updateX(int pos, int val)
{
x[pos+1]=val;updata(pos+1,1,n,1);
return tree[1].mx;
}
int updateY(int pos, int val)
{
y[pos+1]=val;updata(pos+1,1,n,1);
return tree[1].mx;
}
Compilation message
horses.cpp: In function 'void pushup(int)':
horses.cpp:28:60: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
tree[now].mx=1LL*tree[now<<1].num*tree[now<<1|1].mx%mod;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
horses.cpp:30:58: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
tree[now].num=1LL*tree[now<<1].num*tree[now<<1|1].num%mod;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
horses.cpp: In function 'void build(int, int, int)':
horses.cpp:38:35: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
tree[now].mx=1LL*x[l]*y[l]%mod;
~~~~~~~~~~~~~^~~~
horses.cpp: In function 'void updata(int, int, int, int)':
horses.cpp:53:35: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
tree[now].mx=1LL*x[l]*y[l]%mod;
~~~~~~~~~~~~~^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
512 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
3 ms |
384 KB |
Output is correct |
9 |
Correct |
3 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
0 ms |
384 KB |
Output is correct |
12 |
Correct |
3 ms |
384 KB |
Output is correct |
13 |
Correct |
3 ms |
384 KB |
Output is correct |
14 |
Correct |
2 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
2 ms |
384 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Correct |
3 ms |
384 KB |
Output is correct |
19 |
Correct |
2 ms |
384 KB |
Output is correct |
20 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
3 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
2 ms |
384 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
13 |
Correct |
2 ms |
384 KB |
Output is correct |
14 |
Correct |
3 ms |
384 KB |
Output is correct |
15 |
Correct |
3 ms |
384 KB |
Output is correct |
16 |
Correct |
2 ms |
384 KB |
Output is correct |
17 |
Correct |
3 ms |
384 KB |
Output is correct |
18 |
Correct |
3 ms |
384 KB |
Output is correct |
19 |
Correct |
2 ms |
384 KB |
Output is correct |
20 |
Correct |
2 ms |
384 KB |
Output is correct |
21 |
Correct |
3 ms |
384 KB |
Output is correct |
22 |
Correct |
2 ms |
384 KB |
Output is correct |
23 |
Correct |
3 ms |
512 KB |
Output is correct |
24 |
Correct |
3 ms |
512 KB |
Output is correct |
25 |
Correct |
3 ms |
424 KB |
Output is correct |
26 |
Correct |
3 ms |
384 KB |
Output is correct |
27 |
Correct |
4 ms |
384 KB |
Output is correct |
28 |
Correct |
3 ms |
384 KB |
Output is correct |
29 |
Correct |
3 ms |
412 KB |
Output is correct |
30 |
Correct |
3 ms |
512 KB |
Output is correct |
31 |
Correct |
4 ms |
384 KB |
Output is correct |
32 |
Correct |
4 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
119 ms |
33796 KB |
Output is correct |
2 |
Correct |
220 ms |
33864 KB |
Output is correct |
3 |
Correct |
210 ms |
37624 KB |
Output is correct |
4 |
Correct |
234 ms |
41624 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
3 ms |
384 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
13 |
Correct |
2 ms |
384 KB |
Output is correct |
14 |
Correct |
2 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
412 KB |
Output is correct |
16 |
Correct |
3 ms |
384 KB |
Output is correct |
17 |
Correct |
3 ms |
384 KB |
Output is correct |
18 |
Correct |
2 ms |
384 KB |
Output is correct |
19 |
Correct |
3 ms |
384 KB |
Output is correct |
20 |
Correct |
2 ms |
384 KB |
Output is correct |
21 |
Correct |
2 ms |
384 KB |
Output is correct |
22 |
Correct |
3 ms |
384 KB |
Output is correct |
23 |
Correct |
4 ms |
384 KB |
Output is correct |
24 |
Correct |
4 ms |
384 KB |
Output is correct |
25 |
Correct |
1 ms |
512 KB |
Output is correct |
26 |
Correct |
3 ms |
512 KB |
Output is correct |
27 |
Correct |
3 ms |
256 KB |
Output is correct |
28 |
Correct |
3 ms |
512 KB |
Output is correct |
29 |
Correct |
3 ms |
384 KB |
Output is correct |
30 |
Correct |
2 ms |
384 KB |
Output is correct |
31 |
Correct |
2 ms |
384 KB |
Output is correct |
32 |
Correct |
3 ms |
384 KB |
Output is correct |
33 |
Correct |
90 ms |
36848 KB |
Output is correct |
34 |
Correct |
108 ms |
36984 KB |
Output is correct |
35 |
Correct |
114 ms |
43768 KB |
Output is correct |
36 |
Correct |
113 ms |
43768 KB |
Output is correct |
37 |
Correct |
66 ms |
35064 KB |
Output is correct |
38 |
Correct |
82 ms |
35960 KB |
Output is correct |
39 |
Correct |
54 ms |
34936 KB |
Output is correct |
40 |
Correct |
102 ms |
38796 KB |
Output is correct |
41 |
Correct |
58 ms |
35064 KB |
Output is correct |
42 |
Correct |
57 ms |
34936 KB |
Output is correct |
43 |
Correct |
97 ms |
39440 KB |
Output is correct |
44 |
Correct |
88 ms |
39160 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
428 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
3 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
2 ms |
384 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
13 |
Correct |
2 ms |
384 KB |
Output is correct |
14 |
Correct |
2 ms |
384 KB |
Output is correct |
15 |
Correct |
3 ms |
384 KB |
Output is correct |
16 |
Correct |
3 ms |
384 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Correct |
3 ms |
384 KB |
Output is correct |
19 |
Correct |
2 ms |
384 KB |
Output is correct |
20 |
Correct |
2 ms |
384 KB |
Output is correct |
21 |
Correct |
3 ms |
384 KB |
Output is correct |
22 |
Correct |
2 ms |
384 KB |
Output is correct |
23 |
Correct |
3 ms |
384 KB |
Output is correct |
24 |
Correct |
3 ms |
512 KB |
Output is correct |
25 |
Correct |
2 ms |
384 KB |
Output is correct |
26 |
Correct |
5 ms |
512 KB |
Output is correct |
27 |
Correct |
3 ms |
384 KB |
Output is correct |
28 |
Correct |
3 ms |
384 KB |
Output is correct |
29 |
Correct |
3 ms |
384 KB |
Output is correct |
30 |
Correct |
4 ms |
512 KB |
Output is correct |
31 |
Correct |
3 ms |
484 KB |
Output is correct |
32 |
Correct |
4 ms |
384 KB |
Output is correct |
33 |
Correct |
125 ms |
37712 KB |
Output is correct |
34 |
Correct |
250 ms |
46352 KB |
Output is correct |
35 |
Correct |
216 ms |
37596 KB |
Output is correct |
36 |
Correct |
200 ms |
41352 KB |
Output is correct |
37 |
Correct |
85 ms |
36856 KB |
Output is correct |
38 |
Correct |
93 ms |
36856 KB |
Output is correct |
39 |
Correct |
109 ms |
43824 KB |
Output is correct |
40 |
Correct |
105 ms |
43772 KB |
Output is correct |
41 |
Correct |
57 ms |
35064 KB |
Output is correct |
42 |
Correct |
73 ms |
35868 KB |
Output is correct |
43 |
Correct |
51 ms |
34936 KB |
Output is correct |
44 |
Correct |
95 ms |
38808 KB |
Output is correct |
45 |
Correct |
62 ms |
34936 KB |
Output is correct |
46 |
Correct |
54 ms |
35064 KB |
Output is correct |
47 |
Correct |
81 ms |
39160 KB |
Output is correct |
48 |
Correct |
90 ms |
39160 KB |
Output is correct |
49 |
Correct |
252 ms |
39004 KB |
Output is correct |
50 |
Correct |
229 ms |
38964 KB |
Output is correct |
51 |
Correct |
185 ms |
45560 KB |
Output is correct |
52 |
Correct |
131 ms |
45052 KB |
Output is correct |
53 |
Correct |
186 ms |
37292 KB |
Output is correct |
54 |
Correct |
144 ms |
37624 KB |
Output is correct |
55 |
Correct |
100 ms |
35960 KB |
Output is correct |
56 |
Correct |
132 ms |
40696 KB |
Output is correct |
57 |
Correct |
98 ms |
36600 KB |
Output is correct |
58 |
Correct |
108 ms |
37020 KB |
Output is correct |
59 |
Correct |
96 ms |
39160 KB |
Output is correct |