# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
285079 | 2020-08-28T09:53:50 Z | Shafin666 | 말 (IOI15_horses) | C++14 | 238 ms | 58488 KB |
#include "horses.h" #include <bits/stdc++.h> #define pb push_back #define pii pair<ll, ll> #define nyan "(=^・ω・^=)" #define read_input freopen("in.txt","r", stdin) #define print_output freopen("out.txt","w", stdout) typedef long long ll; typedef long double ld; using namespace std; const int maxn = 5e5+10, mod = 1e9+7; ll x[maxn], y[maxn], n; struct node { double lg; // log x0 + log x1 + ... double mxlg; // max log (x0 x1 x2 .... xi * yi) ll mul; // x0 x1 x2 ... % mod ll mxmul; // max x0 x1 ... xi * yi } tree[4 * maxn]; node merge(node a, node b) { node ret; ret.lg = a.lg + b.lg; ret.mul = (a.mul * b.mul) % mod; if(a.mxlg <= a.lg + b.mxlg) { ret.mxlg = a.lg + b.mxlg; ret.mxmul = (a.mul * b.mxmul) % mod; } else { ret.mxlg = a.mxlg; ret.mxmul = a.mxmul; } return ret; } void build(int at, int L, int R) { if(L == R) { node now; now.lg = log(x[L]); now.mxlg = log(x[L] * y[L]); now.mul = x[L]; now.mxmul = (x[L] * y[L]) % mod; tree[at] = now; return; } int mid = L + R >> 1; build(at<<1, L, mid); build(at<<1|1, mid+1, R); tree[at] = merge(tree[at<<1], tree[at<<1|1]); } void update(int at, int L, int R, int idx) { if(L == R) { node now; now.lg = log(x[L]); now.mxlg = log(x[L] * y[L]); now.mul = x[L]; now.mxmul = (x[L] * y[L]) % mod; tree[at] = now; return; } int mid = L + R >> 1; if(idx <= mid) update(at<<1, L, mid, idx); else update(at<<1|1, mid+1, R, idx); tree[at] = merge(tree[at<<1], tree[at<<1|1]); } 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(1, 0, n-1); return tree[1].mxmul; } int updateX(int pos, int val) { x[pos] = val; update(1, 0, n-1, pos); return tree[1].mxmul; } int updateY(int pos, int val) { y[pos] = val; update(1, 0, n-1, pos); return tree[1].mxmul; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 0 ms | 384 KB | Output is correct |
6 | Correct | 0 ms | 384 KB | Output is correct |
7 | Correct | 1 ms | 384 KB | Output is correct |
8 | Correct | 1 ms | 384 KB | Output is correct |
9 | Correct | 1 ms | 384 KB | Output is correct |
10 | Correct | 1 ms | 384 KB | Output is correct |
11 | Correct | 0 ms | 384 KB | Output is correct |
12 | Correct | 0 ms | 384 KB | Output is correct |
13 | Correct | 1 ms | 384 KB | Output is correct |
14 | Correct | 0 ms | 384 KB | Output is correct |
15 | Correct | 1 ms | 384 KB | Output is correct |
16 | Correct | 0 ms | 384 KB | Output is correct |
17 | Correct | 1 ms | 384 KB | Output is correct |
18 | Correct | 1 ms | 384 KB | Output is correct |
19 | Correct | 1 ms | 384 KB | Output is correct |
20 | Correct | 1 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 0 ms | 384 KB | Output is correct |
4 | Correct | 0 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 1 ms | 384 KB | Output is correct |
7 | Correct | 0 ms | 384 KB | Output is correct |
8 | Correct | 1 ms | 384 KB | Output is correct |
9 | Correct | 1 ms | 512 KB | Output is correct |
10 | Correct | 0 ms | 384 KB | Output is correct |
11 | Correct | 1 ms | 384 KB | Output is correct |
12 | Correct | 1 ms | 384 KB | Output is correct |
13 | Correct | 1 ms | 384 KB | Output is correct |
14 | Correct | 0 ms | 384 KB | Output is correct |
15 | Correct | 1 ms | 384 KB | Output is correct |
16 | Correct | 1 ms | 384 KB | Output is correct |
17 | Correct | 0 ms | 384 KB | Output is correct |
18 | Correct | 1 ms | 384 KB | Output is correct |
19 | Correct | 1 ms | 384 KB | Output is correct |
20 | Correct | 0 ms | 384 KB | Output is correct |
21 | Correct | 0 ms | 384 KB | Output is correct |
22 | Correct | 1 ms | 384 KB | Output is correct |
23 | Correct | 2 ms | 512 KB | Output is correct |
24 | Correct | 1 ms | 512 KB | Output is correct |
25 | Correct | 1 ms | 512 KB | Output is correct |
26 | Correct | 1 ms | 512 KB | Output is correct |
27 | Correct | 1 ms | 512 KB | Output is correct |
28 | Correct | 1 ms | 512 KB | Output is correct |
29 | Correct | 1 ms | 384 KB | Output is correct |
30 | Correct | 1 ms | 512 KB | Output is correct |
31 | Correct | 1 ms | 512 KB | Output is correct |
32 | Correct | 1 ms | 512 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 131 ms | 49784 KB | Output is correct |
2 | Correct | 238 ms | 58488 KB | Output is correct |
3 | Correct | 199 ms | 49784 KB | Output is correct |
4 | Correct | 232 ms | 53496 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 0 ms | 384 KB | Output is correct |
5 | Correct | 0 ms | 384 KB | Output is correct |
6 | Correct | 0 ms | 384 KB | Output is correct |
7 | Correct | 1 ms | 384 KB | Output is correct |
8 | Correct | 1 ms | 384 KB | Output is correct |
9 | Correct | 0 ms | 384 KB | Output is correct |
10 | Correct | 1 ms | 384 KB | Output is correct |
11 | Correct | 0 ms | 384 KB | Output is correct |
12 | Correct | 1 ms | 384 KB | Output is correct |
13 | Correct | 1 ms | 384 KB | Output is correct |
14 | Correct | 1 ms | 384 KB | Output is correct |
15 | Correct | 1 ms | 384 KB | Output is correct |
16 | Correct | 1 ms | 384 KB | Output is correct |
17 | Correct | 0 ms | 384 KB | Output is correct |
18 | Correct | 1 ms | 384 KB | Output is correct |
19 | Correct | 1 ms | 384 KB | Output is correct |
20 | Correct | 0 ms | 384 KB | Output is correct |
21 | Correct | 1 ms | 384 KB | Output is correct |
22 | Correct | 0 ms | 384 KB | Output is correct |
23 | Correct | 1 ms | 512 KB | Output is correct |
24 | Correct | 2 ms | 512 KB | Output is correct |
25 | Correct | 1 ms | 512 KB | Output is correct |
26 | Correct | 1 ms | 512 KB | Output is correct |
27 | Correct | 1 ms | 512 KB | Output is correct |
28 | Correct | 1 ms | 512 KB | Output is correct |
29 | Correct | 1 ms | 384 KB | Output is correct |
30 | Correct | 1 ms | 512 KB | Output is correct |
31 | Correct | 1 ms | 512 KB | Output is correct |
32 | Correct | 1 ms | 512 KB | Output is correct |
33 | Correct | 98 ms | 48888 KB | Output is correct |
34 | Correct | 91 ms | 49016 KB | Output is correct |
35 | Correct | 126 ms | 56056 KB | Output is correct |
36 | Correct | 121 ms | 55800 KB | Output is correct |
37 | Correct | 59 ms | 47096 KB | Output is correct |
38 | Correct | 88 ms | 47976 KB | Output is correct |
39 | Correct | 53 ms | 47096 KB | Output is correct |
40 | Correct | 103 ms | 51064 KB | Output is correct |
41 | Correct | 53 ms | 47096 KB | Output is correct |
42 | Correct | 52 ms | 47096 KB | Output is correct |
43 | Correct | 98 ms | 51320 KB | Output is correct |
44 | Correct | 97 ms | 51324 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 0 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 0 ms | 384 KB | Output is correct |
7 | Correct | 1 ms | 384 KB | Output is correct |
8 | Correct | 1 ms | 384 KB | Output is correct |
9 | Correct | 0 ms | 384 KB | Output is correct |
10 | Correct | 1 ms | 384 KB | Output is correct |
11 | Correct | 1 ms | 384 KB | Output is correct |
12 | Correct | 1 ms | 384 KB | Output is correct |
13 | Correct | 1 ms | 384 KB | Output is correct |
14 | Correct | 0 ms | 384 KB | Output is correct |
15 | Correct | 1 ms | 384 KB | Output is correct |
16 | Correct | 0 ms | 384 KB | Output is correct |
17 | Correct | 1 ms | 384 KB | Output is correct |
18 | Correct | 1 ms | 384 KB | Output is correct |
19 | Correct | 0 ms | 384 KB | Output is correct |
20 | Correct | 1 ms | 384 KB | Output is correct |
21 | Correct | 1 ms | 384 KB | Output is correct |
22 | Correct | 0 ms | 384 KB | Output is correct |
23 | Correct | 1 ms | 512 KB | Output is correct |
24 | Correct | 1 ms | 512 KB | Output is correct |
25 | Correct | 1 ms | 512 KB | Output is correct |
26 | Correct | 1 ms | 512 KB | Output is correct |
27 | Correct | 1 ms | 512 KB | Output is correct |
28 | Correct | 1 ms | 512 KB | Output is correct |
29 | Correct | 1 ms | 384 KB | Output is correct |
30 | Correct | 1 ms | 512 KB | Output is correct |
31 | Correct | 1 ms | 512 KB | Output is correct |
32 | Correct | 1 ms | 512 KB | Output is correct |
33 | Correct | 128 ms | 49708 KB | Output is correct |
34 | Correct | 237 ms | 58488 KB | Output is correct |
35 | Correct | 199 ms | 49784 KB | Output is correct |
36 | Correct | 221 ms | 53568 KB | Output is correct |
37 | Correct | 99 ms | 48888 KB | Output is correct |
38 | Correct | 95 ms | 48888 KB | Output is correct |
39 | Correct | 123 ms | 55824 KB | Output is correct |
40 | Correct | 123 ms | 55800 KB | Output is correct |
41 | Correct | 60 ms | 47096 KB | Output is correct |
42 | Correct | 96 ms | 47992 KB | Output is correct |
43 | Correct | 59 ms | 46968 KB | Output is correct |
44 | Correct | 101 ms | 50936 KB | Output is correct |
45 | Correct | 49 ms | 47096 KB | Output is correct |
46 | Correct | 60 ms | 47096 KB | Output is correct |
47 | Correct | 100 ms | 51236 KB | Output is correct |
48 | Correct | 101 ms | 51344 KB | Output is correct |
49 | Correct | 203 ms | 50956 KB | Output is correct |
50 | Correct | 202 ms | 50936 KB | Output is correct |
51 | Correct | 163 ms | 57720 KB | Output is correct |
52 | Correct | 171 ms | 57208 KB | Output is correct |
53 | Correct | 164 ms | 49272 KB | Output is correct |
54 | Correct | 140 ms | 49876 KB | Output is correct |
55 | Correct | 119 ms | 48124 KB | Output is correct |
56 | Correct | 143 ms | 52728 KB | Output is correct |
57 | Correct | 93 ms | 48848 KB | Output is correct |
58 | Correct | 92 ms | 49228 KB | Output is correct |
59 | Correct | 94 ms | 51320 KB | Output is correct |