# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
68988 | 2018-08-19T12:15:40 Z | theknife2001 | Horses (IOI15_horses) | C++17 | 235 ms | 38408 KB |
#include "horses.h" //#include "grader.cpp" #include <bits/stdc++.h> #define mid (l+r)/2 using namespace std; const int N=5e5+55; long long tree[N*4]; long long x[N]; long long y[N]; int n; int m=1e9+7; void build(int l , int r , int node) { if(l==r) { tree[node]=x[l]; return ; } build(l,mid,node*2); build(mid+1,r,node*2+1); tree[node]=tree[node*2]*tree[node*2+1]; tree[node]%=m; } void update(int l , int r , int node , int ind , int val) { if(l==r&&l==ind) { tree[node]=val; return ; } if(ind<=mid) update(l,mid,node*2,ind,val); else update(mid+1,r,node*2+1,ind,val); tree[node]=tree[node*2]*tree[node*2+1]; tree[node]%=m; } long long query(int l , int r , int node , int x , int y) { if(x<=l&&r<=y) return tree[node]; if(l>y||r<x) return 1; return (query(l,mid,node*2,x,y)*query(mid+1,r,node*2+1,x,y))%m; } int solve() { int i=n-1; long long ret=0; long long temp=1; long long s=1; while(i--) { s*=x[i]; if(s>1000000000) break; } i++; int bestpos=n-1; for(;i<n;i++) { temp*=x[i]; if(y[i]*temp>ret) { ret=y[i]*temp; bestpos=i; } } return (y[bestpos]*query(0,n-1,1,0,bestpos))%m; } int init(int N, int X[], int Y[]) { n=N; for(int i=0;i<N;i++) { x[i]=X[i]; y[i]=Y[i]; } build(0,n-1,1); return solve(); } int updateX(int pos, int val) { x[pos]=val; update(0,n-1,1,pos,val); return solve(); } int updateY(int pos, int val) { y[pos]=val; return solve(); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 4 ms | 488 KB | Output is correct |
3 | Correct | 3 ms | 488 KB | Output is correct |
4 | Correct | 3 ms | 488 KB | Output is correct |
5 | Correct | 3 ms | 656 KB | Output is correct |
6 | Correct | 3 ms | 660 KB | Output is correct |
7 | Correct | 3 ms | 660 KB | Output is correct |
8 | Correct | 2 ms | 660 KB | Output is correct |
9 | Correct | 3 ms | 660 KB | Output is correct |
10 | Correct | 3 ms | 696 KB | Output is correct |
11 | Correct | 3 ms | 696 KB | Output is correct |
12 | Correct | 3 ms | 696 KB | Output is correct |
13 | Correct | 2 ms | 696 KB | Output is correct |
14 | Correct | 2 ms | 696 KB | Output is correct |
15 | Correct | 3 ms | 696 KB | Output is correct |
16 | Correct | 3 ms | 696 KB | Output is correct |
17 | Correct | 3 ms | 768 KB | Output is correct |
18 | Correct | 3 ms | 768 KB | Output is correct |
19 | Correct | 3 ms | 768 KB | Output is correct |
20 | Correct | 2 ms | 804 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 804 KB | Output is correct |
2 | Correct | 3 ms | 804 KB | Output is correct |
3 | Correct | 2 ms | 804 KB | Output is correct |
4 | Correct | 3 ms | 804 KB | Output is correct |
5 | Correct | 3 ms | 804 KB | Output is correct |
6 | Correct | 3 ms | 804 KB | Output is correct |
7 | Correct | 2 ms | 804 KB | Output is correct |
8 | Correct | 3 ms | 804 KB | Output is correct |
9 | Correct | 2 ms | 804 KB | Output is correct |
10 | Correct | 2 ms | 804 KB | Output is correct |
11 | Correct | 2 ms | 804 KB | Output is correct |
12 | Correct | 3 ms | 804 KB | Output is correct |
13 | Correct | 3 ms | 804 KB | Output is correct |
14 | Correct | 2 ms | 804 KB | Output is correct |
15 | Correct | 3 ms | 804 KB | Output is correct |
16 | Correct | 2 ms | 804 KB | Output is correct |
17 | Correct | 4 ms | 804 KB | Output is correct |
18 | Correct | 2 ms | 804 KB | Output is correct |
19 | Correct | 4 ms | 804 KB | Output is correct |
20 | Correct | 3 ms | 804 KB | Output is correct |
21 | Correct | 3 ms | 804 KB | Output is correct |
22 | Correct | 2 ms | 804 KB | Output is correct |
23 | Incorrect | 4 ms | 804 KB | Output isn't correct |
24 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 114 ms | 25472 KB | Output is correct |
2 | Incorrect | 235 ms | 38408 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 38408 KB | Output is correct |
2 | Correct | 2 ms | 38408 KB | Output is correct |
3 | Correct | 2 ms | 38408 KB | Output is correct |
4 | Correct | 2 ms | 38408 KB | Output is correct |
5 | Correct | 2 ms | 38408 KB | Output is correct |
6 | Correct | 3 ms | 38408 KB | Output is correct |
7 | Correct | 3 ms | 38408 KB | Output is correct |
8 | Correct | 3 ms | 38408 KB | Output is correct |
9 | Correct | 3 ms | 38408 KB | Output is correct |
10 | Correct | 3 ms | 38408 KB | Output is correct |
11 | Correct | 3 ms | 38408 KB | Output is correct |
12 | Correct | 3 ms | 38408 KB | Output is correct |
13 | Correct | 2 ms | 38408 KB | Output is correct |
14 | Correct | 3 ms | 38408 KB | Output is correct |
15 | Correct | 4 ms | 38408 KB | Output is correct |
16 | Correct | 3 ms | 38408 KB | Output is correct |
17 | Correct | 3 ms | 38408 KB | Output is correct |
18 | Correct | 3 ms | 38408 KB | Output is correct |
19 | Correct | 2 ms | 38408 KB | Output is correct |
20 | Correct | 3 ms | 38408 KB | Output is correct |
21 | Correct | 3 ms | 38408 KB | Output is correct |
22 | Correct | 3 ms | 38408 KB | Output is correct |
23 | Incorrect | 4 ms | 38408 KB | Output isn't correct |
24 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 38408 KB | Output is correct |
2 | Correct | 2 ms | 38408 KB | Output is correct |
3 | Correct | 3 ms | 38408 KB | Output is correct |
4 | Correct | 2 ms | 38408 KB | Output is correct |
5 | Correct | 2 ms | 38408 KB | Output is correct |
6 | Correct | 2 ms | 38408 KB | Output is correct |
7 | Correct | 2 ms | 38408 KB | Output is correct |
8 | Correct | 2 ms | 38408 KB | Output is correct |
9 | Correct | 2 ms | 38408 KB | Output is correct |
10 | Correct | 3 ms | 38408 KB | Output is correct |
11 | Correct | 3 ms | 38408 KB | Output is correct |
12 | Correct | 2 ms | 38408 KB | Output is correct |
13 | Correct | 2 ms | 38408 KB | Output is correct |
14 | Correct | 2 ms | 38408 KB | Output is correct |
15 | Correct | 3 ms | 38408 KB | Output is correct |
16 | Correct | 2 ms | 38408 KB | Output is correct |
17 | Correct | 3 ms | 38408 KB | Output is correct |
18 | Correct | 2 ms | 38408 KB | Output is correct |
19 | Correct | 3 ms | 38408 KB | Output is correct |
20 | Correct | 3 ms | 38408 KB | Output is correct |
21 | Correct | 3 ms | 38408 KB | Output is correct |
22 | Correct | 2 ms | 38408 KB | Output is correct |
23 | Incorrect | 4 ms | 38408 KB | Output isn't correct |
24 | Halted | 0 ms | 0 KB | - |