# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1080151 | 2024-08-29T07:27:55 Z | Trumling | Horses (IOI15_horses) | C++14 | 1500 ms | 27748 KB |
#include "horses.h" #include<bits/stdc++.h> using namespace std; #define F first #define S second #define pb push_back #define all(x) x.begin(),x.end() #define INF 9999999999999999 #define MOD 1000000007 typedef long long ll; ll n; ll sell; vector<int>x,y; ll seg[2000001]; void build(int idx,int l,int r) { if(l==r) { seg[idx]=x[l]; return ; } build(idx*2,l,(l+r)/2); build(idx*2+1,(l+r)/2+1,r); seg[idx]=(seg[idx*2]*seg[idx*2+1])%MOD; } void update(int idx,int l,int r,int p) { if(r<p || l>p) return ; if(l==r) { seg[idx]=x[p]; return ; } update(idx*2,l,(l+r)/2,p); update(idx*2+1,(l+r)/2+1,r,p); seg[idx]=(seg[idx*2]*seg[idx*2+1])%MOD; } ll query(int idx,int L,int R,int l,int r) { if(r<L || l>R) return 1; if(L<=l && r<=R) return seg[idx]; return (query(idx*2,L,R,l,(l+r)/2)*query(idx*2+1,L,R,(l+r)/2+1,r))%MOD; } int init(int N, int X[], int Y[]) { n=N; for(int i=0;i<n;i++) { x.pb(X[i]); y.pb(Y[i]); } build(1,0,n-1); sell=n-1; ll curr=1; for(int i=n-1;i>=0;i--) { if(y[sell]*curr < y[i]) { sell=i; curr=1; } curr*=x[i]; if(curr*y[sell]>=MOD) break; } return (query(1,0,sell,0,n-1)*y[sell])%MOD; } int updateX(int pos, int val) { x[pos]=val; update(1,0,n-1,pos); sell=n-1; ll curr=1; for(int i=n-1;i>=0;i--) { if(y[sell]*curr < y[i]) { sell=i; curr=1; } curr*=x[i]; if(curr*y[sell]>=MOD) break; } return (query(1,0,sell,0,n-1)*y[sell])%MOD; } int updateY(int pos, int val) { y[pos]=val; sell=n-1; ll curr=1; for(int i=n-1;i>=0;i--) { if(y[sell]*curr < y[i]) { sell=i; curr=1; } curr*=x[i]; if(curr*y[sell]>=MOD) break; } return (query(1,0,sell,0,n-1)*y[sell])%MOD; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 344 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 344 KB | Output is correct |
12 | Correct | 0 ms | 344 KB | Output is correct |
13 | Correct | 0 ms | 344 KB | Output is correct |
14 | Correct | 1 ms | 344 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 1 ms | 348 KB | Output is correct |
17 | Correct | 0 ms | 348 KB | Output is correct |
18 | Correct | 0 ms | 348 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 344 KB | Output is correct |
16 | Correct | 1 ms | 360 KB | Output is correct |
17 | Correct | 0 ms | 348 KB | Output is correct |
18 | Correct | 1 ms | 348 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 0 ms | 348 KB | Output is correct |
21 | Correct | 1 ms | 344 KB | Output is correct |
22 | Correct | 1 ms | 348 KB | Output is correct |
23 | Correct | 1 ms | 348 KB | Output is correct |
24 | Correct | 1 ms | 344 KB | Output is correct |
25 | Correct | 1 ms | 348 KB | Output is correct |
26 | Correct | 0 ms | 348 KB | Output is correct |
27 | Correct | 1 ms | 348 KB | Output is correct |
28 | Correct | 1 ms | 348 KB | Output is correct |
29 | Correct | 3 ms | 348 KB | Output is correct |
30 | Correct | 1 ms | 348 KB | Output is correct |
31 | Correct | 2 ms | 348 KB | Output is correct |
32 | Correct | 2 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 51 ms | 17844 KB | Output is correct |
2 | Correct | 71 ms | 19416 KB | Output is correct |
3 | Correct | 45 ms | 21424 KB | Output is correct |
4 | Correct | 75 ms | 25608 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 1 ms | 344 KB | Output is correct |
14 | Correct | 0 ms | 344 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 0 ms | 348 KB | Output is correct |
17 | Correct | 0 ms | 348 KB | Output is correct |
18 | Correct | 0 ms | 348 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 0 ms | 348 KB | Output is correct |
21 | Correct | 0 ms | 344 KB | Output is correct |
22 | Correct | 0 ms | 348 KB | Output is correct |
23 | Correct | 1 ms | 348 KB | Output is correct |
24 | Correct | 1 ms | 348 KB | Output is correct |
25 | Correct | 0 ms | 348 KB | Output is correct |
26 | Correct | 1 ms | 348 KB | Output is correct |
27 | Correct | 1 ms | 348 KB | Output is correct |
28 | Correct | 1 ms | 480 KB | Output is correct |
29 | Correct | 2 ms | 348 KB | Output is correct |
30 | Correct | 1 ms | 348 KB | Output is correct |
31 | Correct | 2 ms | 344 KB | Output is correct |
32 | Correct | 1 ms | 348 KB | Output is correct |
33 | Correct | 55 ms | 16832 KB | Output is correct |
34 | Correct | 27 ms | 20664 KB | Output is correct |
35 | Correct | 55 ms | 27704 KB | Output is correct |
36 | Correct | 54 ms | 27744 KB | Output is correct |
37 | Correct | 412 ms | 19252 KB | Output is correct |
38 | Correct | 26 ms | 19900 KB | Output is correct |
39 | Execution timed out | 1524 ms | 18868 KB | Time limit exceeded |
40 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 1 ms | 344 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 1 ms | 348 KB | Output is correct |
17 | Correct | 0 ms | 348 KB | Output is correct |
18 | Correct | 0 ms | 348 KB | Output is correct |
19 | Correct | 1 ms | 348 KB | Output is correct |
20 | Correct | 0 ms | 348 KB | Output is correct |
21 | Correct | 0 ms | 348 KB | Output is correct |
22 | Correct | 0 ms | 348 KB | Output is correct |
23 | Correct | 1 ms | 348 KB | Output is correct |
24 | Correct | 1 ms | 348 KB | Output is correct |
25 | Correct | 1 ms | 348 KB | Output is correct |
26 | Correct | 1 ms | 348 KB | Output is correct |
27 | Correct | 1 ms | 348 KB | Output is correct |
28 | Correct | 1 ms | 348 KB | Output is correct |
29 | Correct | 2 ms | 348 KB | Output is correct |
30 | Correct | 1 ms | 348 KB | Output is correct |
31 | Correct | 3 ms | 348 KB | Output is correct |
32 | Correct | 1 ms | 492 KB | Output is correct |
33 | Correct | 53 ms | 17736 KB | Output is correct |
34 | Correct | 74 ms | 19380 KB | Output is correct |
35 | Correct | 58 ms | 21548 KB | Output is correct |
36 | Correct | 74 ms | 25268 KB | Output is correct |
37 | Correct | 58 ms | 20768 KB | Output is correct |
38 | Correct | 29 ms | 20664 KB | Output is correct |
39 | Correct | 53 ms | 27748 KB | Output is correct |
40 | Correct | 52 ms | 27604 KB | Output is correct |
41 | Correct | 414 ms | 18880 KB | Output is correct |
42 | Correct | 25 ms | 19896 KB | Output is correct |
43 | Execution timed out | 1542 ms | 18876 KB | Time limit exceeded |
44 | Halted | 0 ms | 0 KB | - |