#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
using namespace std;
int n, tr[2000000];
ll now=1;
vector<int>x, y, a;
void pre(){
int last=-1;
a.push_back(0);
for(int i=1; i<n; i++){
if(x[i]>1){
a.push_back(i);
}
}
}
void build(int ind, int l, int r){
if(l==r){
tr[ind]=y[l];
return;
}
build(ind*2, l, (l+r)/2);
build(ind*2+1, (l+r)/2+1, r);
tr[ind]=max(tr[ind*2], tr[ind*2+1]);
}
void upd(int ind, int l, int r, int L, int val){
if(l==r) tr[ind]=val;
int m=(l+r)/2;
if(L<=m) upd(ind*2, l, m, L, val);
else upd(ind*2+1, m+1, r, L, val);
}
ll rmq(int ind, int l, int r, int L, int R){
if(l==L && r==R) return tr[ind];
int m=(l+r)/2;
if(R<=m) return rmq(ind*2, l, m, L, R);
else if(L>m) return rmq(ind*2+1, m+1, r, L, R);
else{
return max(rmq(ind*2, l, m, L, m), rmq(ind*2+1, m+1, r, m+1, R));
}
}
ll find(){
int last=a.size()-1, ind=a.size();
ll ans=1;
ll now=rmq(1, 0, n-1, a[last], n-1);
for(int i=a.size()-1; i>=0 && now<mod; i--){
if(now*x[a[i]]>mod) break;
now*=x[a[i]];
ind=i;
}
ans=now;
now/=rmq(1, 0, n-1, a[last], n-1);
for(int i=a.size()-2; i>=ind; i--){
now/=x[a[i+1]];
ans=max(ans, now*rmq(1, 0, n-1, a[i], a[i+1]-1));
}
for(int i=ind-1; i>=0; i--){
ans*=x[i];
ans%=mod;
}
return ans;
}
int init(int N, int X[], int Y[]) {
n=N;
for(int i=0; i<n; i++) {x.push_back(X[i]); y.push_back(Y[i]);}
pre();
build(1, 0, n-1);
return find();
}
int updateX(int pos, int val){
return 0;
}
int updateY(int pos, int val){
//upd(1, 0, n-1, pos, val);
return 0;
}
Compilation message
horses.cpp: In function 'void pre()':
horses.cpp:11:6: warning: unused variable 'last' [-Wunused-variable]
int last=-1;
^~~~
horses.cpp: In function 'long long int find()':
horses.cpp:48:19: warning: conversion to 'int' from 'std::vector<int>::size_type {aka long unsigned int}' may alter its value [-Wconversion]
int last=a.size()-1, ind=a.size();
~~~~~~~~^~
horses.cpp:48:33: warning: conversion to 'int' from 'std::vector<int>::size_type {aka long unsigned int}' may alter its value [-Wconversion]
int last=a.size()-1, ind=a.size();
~~~~~~^~
horses.cpp:50:5: warning: declaration of 'now' shadows a global declaration [-Wshadow]
ll now=rmq(1, 0, n-1, a[last], n-1);
^~~
horses.cpp:7:4: note: shadowed declaration is here
ll now=1;
^~~
horses.cpp:51:20: warning: conversion to 'int' from 'std::vector<int>::size_type {aka long unsigned int}' may alter its value [-Wconversion]
for(int i=a.size()-1; i>=0 && now<mod; i--){
~~~~~~~~^~
horses.cpp:58:20: warning: conversion to 'int' from 'std::vector<int>::size_type {aka long unsigned int}' may alter its value [-Wconversion]
for(int i=a.size()-2; i>=ind; i--){
~~~~~~~~^~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:74:13: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
return find();
~~~~^~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:77:17: warning: unused parameter 'pos' [-Wunused-parameter]
int updateX(int pos, int val){
^~~
horses.cpp:77:26: warning: unused parameter 'val' [-Wunused-parameter]
int updateX(int pos, int val){
^~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:82:17: warning: unused parameter 'pos' [-Wunused-parameter]
int updateY(int pos, int val){
^~~
horses.cpp:82:26: warning: unused parameter 'val' [-Wunused-parameter]
int updateY(int pos, int val){
^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
472 KB |
Output is correct |
3 |
Correct |
2 ms |
472 KB |
Output is correct |
4 |
Correct |
2 ms |
472 KB |
Output is correct |
5 |
Correct |
3 ms |
472 KB |
Output is correct |
6 |
Correct |
3 ms |
472 KB |
Output is correct |
7 |
Correct |
2 ms |
472 KB |
Output is correct |
8 |
Correct |
3 ms |
472 KB |
Output is correct |
9 |
Correct |
3 ms |
472 KB |
Output is correct |
10 |
Correct |
3 ms |
552 KB |
Output is correct |
11 |
Correct |
2 ms |
592 KB |
Output is correct |
12 |
Correct |
2 ms |
592 KB |
Output is correct |
13 |
Correct |
2 ms |
616 KB |
Output is correct |
14 |
Correct |
2 ms |
628 KB |
Output is correct |
15 |
Correct |
3 ms |
628 KB |
Output is correct |
16 |
Correct |
3 ms |
744 KB |
Output is correct |
17 |
Correct |
3 ms |
760 KB |
Output is correct |
18 |
Correct |
3 ms |
760 KB |
Output is correct |
19 |
Correct |
2 ms |
760 KB |
Output is correct |
20 |
Correct |
3 ms |
760 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
760 KB |
Output is correct |
2 |
Correct |
2 ms |
760 KB |
Output is correct |
3 |
Correct |
2 ms |
760 KB |
Output is correct |
4 |
Correct |
2 ms |
760 KB |
Output is correct |
5 |
Correct |
2 ms |
760 KB |
Output is correct |
6 |
Correct |
2 ms |
760 KB |
Output is correct |
7 |
Correct |
2 ms |
760 KB |
Output is correct |
8 |
Correct |
4 ms |
760 KB |
Output is correct |
9 |
Correct |
4 ms |
760 KB |
Output is correct |
10 |
Correct |
3 ms |
760 KB |
Output is correct |
11 |
Correct |
2 ms |
760 KB |
Output is correct |
12 |
Correct |
2 ms |
760 KB |
Output is correct |
13 |
Correct |
4 ms |
760 KB |
Output is correct |
14 |
Correct |
4 ms |
760 KB |
Output is correct |
15 |
Correct |
3 ms |
760 KB |
Output is correct |
16 |
Correct |
3 ms |
760 KB |
Output is correct |
17 |
Correct |
3 ms |
760 KB |
Output is correct |
18 |
Correct |
3 ms |
760 KB |
Output is correct |
19 |
Correct |
3 ms |
760 KB |
Output is correct |
20 |
Correct |
3 ms |
760 KB |
Output is correct |
21 |
Incorrect |
3 ms |
760 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
69 ms |
14812 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
14812 KB |
Output is correct |
2 |
Correct |
5 ms |
14812 KB |
Output is correct |
3 |
Correct |
3 ms |
14812 KB |
Output is correct |
4 |
Correct |
3 ms |
14812 KB |
Output is correct |
5 |
Correct |
2 ms |
14812 KB |
Output is correct |
6 |
Correct |
3 ms |
14812 KB |
Output is correct |
7 |
Correct |
3 ms |
14812 KB |
Output is correct |
8 |
Correct |
3 ms |
14812 KB |
Output is correct |
9 |
Correct |
2 ms |
14812 KB |
Output is correct |
10 |
Correct |
2 ms |
14812 KB |
Output is correct |
11 |
Correct |
2 ms |
14812 KB |
Output is correct |
12 |
Correct |
2 ms |
14812 KB |
Output is correct |
13 |
Correct |
2 ms |
14812 KB |
Output is correct |
14 |
Correct |
2 ms |
14812 KB |
Output is correct |
15 |
Correct |
3 ms |
14812 KB |
Output is correct |
16 |
Correct |
2 ms |
14812 KB |
Output is correct |
17 |
Correct |
3 ms |
14812 KB |
Output is correct |
18 |
Correct |
2 ms |
14812 KB |
Output is correct |
19 |
Correct |
2 ms |
14812 KB |
Output is correct |
20 |
Correct |
3 ms |
14812 KB |
Output is correct |
21 |
Incorrect |
3 ms |
14812 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
14812 KB |
Output is correct |
2 |
Correct |
2 ms |
14812 KB |
Output is correct |
3 |
Correct |
3 ms |
14812 KB |
Output is correct |
4 |
Correct |
2 ms |
14812 KB |
Output is correct |
5 |
Correct |
2 ms |
14812 KB |
Output is correct |
6 |
Correct |
2 ms |
14812 KB |
Output is correct |
7 |
Correct |
3 ms |
14812 KB |
Output is correct |
8 |
Correct |
3 ms |
14812 KB |
Output is correct |
9 |
Correct |
3 ms |
14812 KB |
Output is correct |
10 |
Correct |
2 ms |
14812 KB |
Output is correct |
11 |
Correct |
2 ms |
14812 KB |
Output is correct |
12 |
Correct |
3 ms |
14812 KB |
Output is correct |
13 |
Correct |
4 ms |
14812 KB |
Output is correct |
14 |
Correct |
3 ms |
14812 KB |
Output is correct |
15 |
Correct |
3 ms |
14812 KB |
Output is correct |
16 |
Correct |
2 ms |
14812 KB |
Output is correct |
17 |
Correct |
2 ms |
14812 KB |
Output is correct |
18 |
Correct |
2 ms |
14812 KB |
Output is correct |
19 |
Correct |
3 ms |
14812 KB |
Output is correct |
20 |
Correct |
3 ms |
14812 KB |
Output is correct |
21 |
Incorrect |
3 ms |
14812 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |