# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
159371 | exqt | Jogging (kriii1_J) | C++14 | 101 ms | 7660 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<ll, ll>;
struct Line {
ll x, y; // (xi - x) / yi
double cross(Line &o) {
double t = 1.0 * (x*o.y - o.x*y) / (o.y - y + 1e-18);
return t;
}
double eval(double p) {
return 1.0 * (x - p) / y;
}
};
int main(int argc, char **argv) {
#ifdef LOCAL
freopen("in.txt", "r", stdin);
#endif
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, m; cin >> n >> m;
vector<Line> linesT(n);
for(int i=0; i<n; i++) {
cin >> linesT[i].x >> linesT[i].y;
}
vector<int> qrys(m);
for(int i=0; i<m; i++) cin >> qrys[i];
sort(linesT.begin(), linesT.end(), [&](Line &a, Line &b) {
if(a.x != b.x) return a.x < b.x;
else return a.y < b.y;
});
vector<Line> lines;
for(Line l : linesT) {
if(lines.size() == 0 || lines.back().x != l.x)
lines.push_back(l);
}
vector<double> res(m);
vector<Line> st;
for(int i=m-1; i>=0; i--) {
while(lines.size() && qrys[i] < lines.back().x) {
st.push_back(lines.back());
lines.pop_back();
while(st.size() >= 2 &&
qrys[i] <= st[(int)st.size()-2].cross(st.back())) {
st.pop_back();
}
}
while(st.size() >= 2 &&
qrys[i] <= st[(int)st.size()-2].cross(st.back())) {
st.pop_back();
}
res[i] = (st.size() ? st.back().eval(qrys[i]) : -1.0);
}
cout << fixed;
cout.precision(7);
for(double r : res) cout << (r == -1.0 ? 0.0 : atan(1.0/r)) << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |