Submission #59183

# Submission time Handle Problem Language Result Execution time Memory
59183 2018-07-20T22:49:28 Z Benq Mobile (BOI12_mobile) C++11
80 / 100
299 ms 132096 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 1000001;

int N,L;
pi v[MX];
ld tmp[MX];

ld perp(pd x, pd y) {
    return (y.f*y.f+y.s*y.s-x.f*x.f-x.s*x.s)/(2*y.f-2*x.f);
}

ld dist(pd a, pd b) {
    return sqrt(pow(a.f-b.f,2)+pow(a.s-b.s,2));
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> N >> L;
    int nex = 0;
    F0R(i,N) {
        int x,y; cin >> x >> y; y = abs(y);
        if (nex && v[nex-1].f == x) {
            if (y >= v[nex-1].s) continue;
            else nex --;
        }
        while (nex && tmp[nex-1] >= perp(v[nex-1],{x,y})) nex --;
        v[nex] = {x,y};
        if (nex) tmp[nex] = perp(v[nex-1],v[nex]);
        nex ++;
    }
    ld ans = 0;
    F0R(i,nex) {
        ld mn = (i == 0 ? -INF : tmp[i]);
        ld mx = (i == nex-1 ? INF : tmp[i+1]);
        if (mx < 0 || mn > L) continue;
        mn = max(mn,(ld)0), mx = min(mx,(ld)L);
        ans = max(ans,dist(v[i],{mn,0}));
        ans = max(ans,dist(v[i],{mx,0}));
    }
    cout << fixed << setprecision(6) << ans;
}

/* Look for:
* the exact constraints (multiple sets are too slow for n=10^6 :( ) 
* special cases (n=1?)
* overflow (ll vs int?)
* array bounds
*/
# Verdict Execution time Memory Grader output
1 Correct 3 ms 368 KB Output is correct
2 Correct 2 ms 368 KB Output is correct
3 Correct 2 ms 440 KB Output is correct
4 Correct 2 ms 444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 632 KB Output is correct
2 Correct 2 ms 632 KB Output is correct
3 Correct 2 ms 632 KB Output is correct
4 Correct 2 ms 632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 632 KB Output is correct
2 Correct 4 ms 724 KB Output is correct
3 Correct 3 ms 724 KB Output is correct
4 Correct 4 ms 724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 768 KB Output is correct
2 Correct 5 ms 788 KB Output is correct
3 Correct 3 ms 856 KB Output is correct
4 Correct 3 ms 960 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 968 KB Output is correct
2 Correct 3 ms 1016 KB Output is correct
3 Correct 3 ms 1084 KB Output is correct
4 Correct 5 ms 1252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1252 KB Output is correct
2 Correct 5 ms 1252 KB Output is correct
3 Correct 4 ms 1316 KB Output is correct
4 Correct 5 ms 1356 KB Output is correct
5 Correct 5 ms 1436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 34 ms 2372 KB Output is correct
2 Correct 27 ms 3276 KB Output is correct
3 Correct 16 ms 4012 KB Output is correct
4 Correct 32 ms 5112 KB Output is correct
5 Correct 12 ms 5596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 18 ms 6164 KB Output is correct
2 Correct 19 ms 7036 KB Output is correct
3 Correct 23 ms 8100 KB Output is correct
4 Correct 24 ms 9256 KB Output is correct
5 Correct 27 ms 10708 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 13456 KB Output is correct
2 Correct 22 ms 13456 KB Output is correct
3 Correct 21 ms 14392 KB Output is correct
4 Correct 35 ms 15608 KB Output is correct
5 Correct 20 ms 16412 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 17976 KB Output is correct
2 Correct 26 ms 19400 KB Output is correct
3 Correct 24 ms 20644 KB Output is correct
4 Correct 40 ms 22356 KB Output is correct
5 Correct 28 ms 23608 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 24668 KB Output is correct
2 Correct 24 ms 24668 KB Output is correct
3 Correct 20 ms 24668 KB Output is correct
4 Correct 43 ms 24668 KB Output is correct
5 Correct 39 ms 24668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 145 ms 35512 KB Output is correct
2 Correct 141 ms 35512 KB Output is correct
3 Correct 151 ms 35512 KB Output is correct
4 Correct 192 ms 35512 KB Output is correct
5 Correct 139 ms 35512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 147 ms 35512 KB Output is correct
2 Correct 149 ms 35512 KB Output is correct
3 Correct 122 ms 35512 KB Output is correct
4 Correct 199 ms 35512 KB Output is correct
5 Correct 180 ms 35512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 194 ms 37968 KB Output is correct
2 Correct 172 ms 37968 KB Output is correct
3 Correct 171 ms 37968 KB Output is correct
4 Correct 293 ms 37968 KB Output is correct
5 Correct 200 ms 37968 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 168 ms 37968 KB Output is correct
2 Correct 180 ms 37968 KB Output is correct
3 Correct 141 ms 37968 KB Output is correct
4 Correct 212 ms 37968 KB Output is correct
5 Correct 202 ms 37968 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 208 ms 49224 KB Output is correct
2 Correct 217 ms 49224 KB Output is correct
3 Correct 228 ms 53844 KB Output is correct
4 Correct 289 ms 67372 KB Output is correct
5 Correct 212 ms 76368 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 178 ms 76476 KB Output is correct
2 Correct 168 ms 86336 KB Output is correct
3 Correct 180 ms 95460 KB Output is correct
4 Correct 238 ms 107448 KB Output is correct
5 Correct 212 ms 117672 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 185 ms 132096 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 204 ms 132096 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 255 ms 132096 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 299 ms 132096 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
2 Halted 0 ms 0 KB -