# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
544667 |
2022-04-02T14:18:47 Z |
pokmui9909 |
수족관 2 (KOI13_aqua2) |
C++17 |
|
247 ms |
37488 KB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lf = long double;
#define x first
#define y second
const ll INF = 1e15;
const ll S = (1 << 18);
struct MinSeg{
pair<ll, ll> T[2 * S] = {};
MinSeg(pair<ll, ll> z){fill(T, T + 2 * S, z); }
void update(ll k, pair<ll, ll> v) { update(1, 1, S, k, v); }
pair<ll, ll> query(ll l, ll r) { return query(1, 1, S, l, r); }
void update(ll node, ll s, ll e, ll k, pair<ll, ll> v){
if(s == e){
T[node] = min(T[node], v);
return;
}
ll lch = 2 * node, rch = 2 * node + 1, m = (s + e) / 2;
if(k <= m) update(lch, s, m, k, v);
else update(rch, m + 1, e, k, v);
T[node] = min(T[lch], T[rch]);
}
pair<ll, ll> query(ll node, ll s, ll e, ll l, ll r){
if(r < s || e < l) return {INF, INF};
if(l <= s && e <= r) return T[node];
ll lch = 2 * node, rch = 2 * node + 1, m = (s + e) / 2;
pair<ll, ll> x = query(lch, s, m, l, r);
pair<ll, ll> y = query(rch, m + 1, e, l, r);
return min(x, y);
}
};
MinSeg ST(make_pair(INF, INF));
struct Data{
ll l, r, w, t;
bool operator < (const Data &t) const{
if(l != t.l) return l < t.l;
else return r < t.r;
}
};
ll N, K, M;
pair<ll, ll> P[300005];
Data V[300005];
ll ps[300005];
ll ans = 0;
ll hole(ll l, ll r){
return ps[r] - ps[l - 1];
}
lf dnc(ll l, ll r, ll s){
if(l > r) return 0;
ll mn = ST.query(l, r).x, idx = ST.query(l, r).y;
ll cnt = hole(l, r);
if(cnt){
ll v = (mn - s) * (V[r].r - V[l].l);
ans -= v;
lf p = dnc(l, idx - 1, mn);
lf q = dnc(idx + 1, r, mn);
return max(p, q) + (long double)v / cnt;
} else {
return 0;
}
}
int main(){
cin.tie(0) -> sync_with_stdio(false);
cin >> N;
for(int i = 1; i <= N; i++){
cin >> P[i].x >> P[i].y;
if(i % 2 == 1 && i != 1){
V[i / 2] = {P[i - 1].x, P[i].x, P[i].y, 0};
ans += (P[i].y) * (P[i].x - P[i - 1].x);
M++;
}
}
for(int i = 1; i <= M; i++){
ST.update(i, {V[i].w, i});
}
cin >> K;
for(int i = 1; i <= K; i++){
ll a, b, c, d; cin >> a >> b >> c >> d;
Data t = {a, c, b};
ll idx = lower_bound(V + 1, V + M + 1, t) - V;
V[idx].t = 1;
}
for(int i = 1; i <= M; i++) ps[i] = ps[i - 1] + V[i].t;
cout << fixed;
cout.precision(2);
cout << dnc(1, M, 0) << '\n';
cout.precision(0);
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
8532 KB |
Output is correct |
2 |
Correct |
5 ms |
8496 KB |
Output is correct |
3 |
Correct |
5 ms |
8532 KB |
Output is correct |
4 |
Correct |
5 ms |
8544 KB |
Output is correct |
5 |
Correct |
6 ms |
8540 KB |
Output is correct |
6 |
Correct |
6 ms |
8540 KB |
Output is correct |
7 |
Correct |
5 ms |
8544 KB |
Output is correct |
8 |
Correct |
5 ms |
8532 KB |
Output is correct |
9 |
Correct |
6 ms |
8532 KB |
Output is correct |
10 |
Correct |
6 ms |
8532 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
8532 KB |
Output is correct |
2 |
Correct |
5 ms |
8508 KB |
Output is correct |
3 |
Correct |
6 ms |
8532 KB |
Output is correct |
4 |
Correct |
6 ms |
8576 KB |
Output is correct |
5 |
Correct |
7 ms |
8552 KB |
Output is correct |
6 |
Correct |
7 ms |
8532 KB |
Output is correct |
7 |
Correct |
5 ms |
8548 KB |
Output is correct |
8 |
Correct |
5 ms |
8540 KB |
Output is correct |
9 |
Correct |
7 ms |
8544 KB |
Output is correct |
10 |
Correct |
7 ms |
8544 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
8788 KB |
Output is correct |
2 |
Correct |
7 ms |
8680 KB |
Output is correct |
3 |
Correct |
11 ms |
8804 KB |
Output is correct |
4 |
Correct |
8 ms |
8808 KB |
Output is correct |
5 |
Correct |
8 ms |
8760 KB |
Output is correct |
6 |
Correct |
11 ms |
9060 KB |
Output is correct |
7 |
Correct |
9 ms |
8916 KB |
Output is correct |
8 |
Correct |
9 ms |
8952 KB |
Output is correct |
9 |
Correct |
8 ms |
8788 KB |
Output is correct |
10 |
Correct |
7 ms |
8788 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
188 ms |
23896 KB |
Output is correct |
2 |
Correct |
170 ms |
23472 KB |
Output is correct |
3 |
Correct |
247 ms |
28744 KB |
Output is correct |
4 |
Correct |
183 ms |
28028 KB |
Output is correct |
5 |
Correct |
191 ms |
28832 KB |
Output is correct |
6 |
Correct |
169 ms |
37488 KB |
Output is correct |
7 |
Correct |
212 ms |
33144 KB |
Output is correct |
8 |
Correct |
144 ms |
30712 KB |
Output is correct |
9 |
Correct |
163 ms |
25600 KB |
Output is correct |
10 |
Correct |
150 ms |
24964 KB |
Output is correct |